VB高手解释冒泡排序排序

VB解释下面两句即可

第一,a(i)=((100-10)*rnd+10),100-10能不能直接用90

第二,解释下面两句即可
为什么i=1 to 9,
为什么j=1 to 10-i

for i=1 to 9
for j=1 to 10-i
if a(j)>a(j+1) then

private sub form_load()
dim a(1 to 10) as integer
dim i as integer
dim j as integer
dim temp as integer
print
print "排序前数组:";
for i=1 to 10
randomize
a(i)=((100-10)*rnd+10)
print a(i);" ";
next i
print
for i=1 to 9
for j=1 to 10-i
if a(j)>a(j+1) then
temp=a(j)
a(j)=a(j+1)
a(j+1)=temp
end if
next j
next i
print "排序后数且:";
for i=1 to 10
print a(i);" ";
next i
end sub

第一,a(i)=((100-10)*rnd+10),100-10能不能直接用90

看个人习惯,喜欢用什么就用什么,用100-10是可读性比较大,90是计算中少了100-10这一步,写成哪一种,纯粹看个人喜好;

第二,我使用的冒泡排序一直不是这样写的;我的写法是这样的:
For i = 1 To 10
For j = 1 To 10 - i
If a(j) > a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i追问

书本和你的都没有错,只不过我想知道
‘为什么i=1 to 9,
为什么j=1 to 10-i
理解不了,你知道吗,解释一下

来自:求助得到的回答
温馨提示:答案为网友推荐,仅供参考
相似回答