回 帖 发 新 帖 刷新版面

主题:It's easy

利用随机函数产生[10,99]之间的随机整数20个,    并对其由大到小排序[em10][em10][em10][em18]

回复列表 (共12个回复)

11 楼

[quote][quote]cls
dim a(20)
for i=1 to 20:a(i)=int(rnd*90)+10:next i
for i=1 to 19
for j=i+1 to 20
if a(i)>a(j) then swap a(i),a(j)
next j,i
for i=1 to 20:print a(i),:next i
end[/quote]
[/quote]

12 楼

CLS
DIM A(20)
RANDOMIZE TIMER
FOR I=1 TO 20
  A(I)=INT(RND*80)+11
NEXT I
FOR I=1 TO 19
  FOR J=I+1 TO 20
    IF A(I)<A(J) THEN SWAP A(I),A(J)
NEXT J,I
FOR I=1 TO 20
  PRINT A(I);
NEXT I
END

我来回复

您尚未登录,请登录后再回复。点此登录或注册