主题:排序
Private Sub Command1_Click()
我是对十个数排序,并输出,大家帮帮忙,怎么这个就是不对呀?哪里错了,输出来 的不对
Dim a As Variant
a = Array(10, 20, 3, 4, 5, 6, 7, 8, 9, 10)
For i = 0 To 8
k = i
For j = i + 1 To 9
If a(j) < a(i) Then
k = j
End If
Next j
If k <> i Then
temp = a(k)
a(k) = a(i)
a(i) = a(k)
End If
Next i
For i = 0 To 9
Print a(i)
Next i
End Sub
我是对十个数排序,并输出,大家帮帮忙,怎么这个就是不对呀?哪里错了,输出来 的不对
Dim a As Variant
a = Array(10, 20, 3, 4, 5, 6, 7, 8, 9, 10)
For i = 0 To 8
k = i
For j = i + 1 To 9
If a(j) < a(i) Then
k = j
End If
Next j
If k <> i Then
temp = a(k)
a(k) = a(i)
a(i) = a(k)
End If
Next i
For i = 0 To 9
Print a(i)
Next i
End Sub