编写一个冒泡排序过程,将随机生成的100个1到1000之间的整数,按从小到大的顺序排列并输出

2024-11-29 01:51:43
推荐回答(2个)
回答(1):

dim A(1 to 100) as integer,i as integer,j as integer,temp as integer
for i=1 to 100
randomize
a(i)=int(rnd()*1000+1)
next i
for i=1 to 99
for j=i+1 to 100
if A(i)>a(j) then
temp=a(i):a(i)=a(j):a(j)=temp
end if
next j
next i
for i=1 to 100
print a(i);
if i mod 10=0 then print
next i

回答(2):

a(i)=int(rnd()*1000+1)
a(i)=int(rnd()*999+1)