这太简单了。
randomize timer
dim a(4)
for i=1 to 4
a(i)=int(rnd(100)+1)
next i
for i=1 to 3
for j=i+1 to 4
if a(i) next j
next i
for i=1 to 4
?a(i);
next i
注:如果要把4改成任意一个从键盘输入的的数字的话,就把程序中的4改成n
并且在程序最前加一个input n即可。
0 number = 10
10 a = int(rnd * number)
15 if a < 3 then 10
20 b = int(rnd * a)
25 if b < 2 then 20
30 c = int(rnd * b)
35 if c < 1 then 30
40 d = int(rnd * c)
50 print a;b;c;d
注:number变量可以改
改第0行就行了!
randomize timer
dim a(4)
for i=1 to 4
a(i)=int(rnd(100)+1)
next i
for i=1 to 3
for j=i+1 to 4
if a(i)next j
next i
for i=1 to 4
?a(i);
next i
RND 随机函数(0至1之间取值)
SWAP 交换函数