有错误~什么情况
Private Sub Form_click()
Dim a%(), imin%, n%, i%, j%, t%, p%
Randomize
i = InputBox("输入数组的元素个数:")
ReDim a(i)
a(i) = Int(Rnd * 201)
n = UBound(a)
For i = 0 To n - 1
imin = i
For j = i + 1 To n
If a(j) < a(imin) Then imin = j
Next j
t = a(i)
a(i) = a(imin)
a(imin) = t
Next i
For i = LBound(a) To UBound(a)
Print a(i);
If i Mod 15 = 0 Then Print
Next
End Sub
用选择排序法实现有n个元素数组的排序。n由键盘输入,数组元素的值在1~200之间,随机产生。
Dim a%(), imin%, n%, i%, j%, t%, p%
Randomize
i = InputBox("输入数组的元素个数:")
ReDim a(i)
a(i) = Int(Rnd * 201)
n = UBound(a)
For i = 0 To n - 1
imin = i
For j = i + 1 To n
If a(j) < a(imin) Then imin = j
Next j
t = a(i)
a(i) = a(imin)
a(imin) = t
Next i
For i = LBound(a) To UBound(a)
Print a(i);
If i Mod 15 = 0 Then Print
Next
End Sub