VB中用选择法将10个整数排序,从小到大排列在另外一个文本框中输出。

2024-12-28 01:37:10
推荐回答(1个)
回答1:

Option Explicit

Private Sub Command1_Click()
Dim A(9) As Integer, i%, m%, t%, AA%
For i = 0 To 9
Randomize
A(i) = Int(Rnd * 90) + 10
Print A(i);
Next

Print
For i = 0 To 8
t = i
For m = i + 1 To 9
If A(m) < A(t) Then t = m
Next m
If t <> i Then AA = A(i): A(i) = A(t): A(t) = AA
Print A(i);
Next i
Print A(9)
End Sub