VB高手解释选择排序排序

1,选择排序和冒泡排序有什么不同

2,下面完全不懂解释一下,

为什么for i=1 to 9
这句什么意思p=i
为什么for j=i+1 to 10
如果a(p)>a(j) then p=j,冒泡好以不用then p=j, 这个p=j有什么用

if a(p)>a(j) then p=j

next j
temp=a(i)
a(i)=a(p)
a(p)=temp
next i

private sub form_load()
dim a(1 to 10) as integer
dim i as integer
dim j as integer
dim temp as integer
dim p 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
p=i
for j=i+1 to 10
if a(p)>a(j) then p=j
next j
temp=a(i)
a(i)=a(p)
a(p)=temp
next i
print "排序后数组:";
for i=1 to 10
print a(i);" ";
next i
end sub

冒泡排序:
for i = 1 to 9
for j = i +1 to 10
if a (i) > a(j) then '当后一项大于前一项的时候
t = a(i) '将a(i)的值保存一下,避免等一下给a(i)赋值的时候吧a(i)原来的值给搞没掉了
a(i) = a(j) '下面两行的作用就是将前后项的值按大小替换
a(j) = t
end if
next j
next i追问

解释这段啊,
for i=1 to 9
p=i
for j=i+1 to 10
if a(p)>a(j) then p=j
next j
temp=a(i)
a(i)=a(p)
a(p)=temp
next i

你这个不知道在说些什么

追答

这个都看不懂你还学什么,最简单的冒泡排序都看不懂的话就别说看别的了,只要你把我上面那段代码看懂其他的你就都看的懂了。

温馨提示:答案为网友推荐,仅供参考