随机产生10个10~100的任意的正整数,要求用选择排序法进行递增排序后,再插入一个数,保持原顺序不变。

2024-12-29 21:56:19
推荐回答(1个)
回答1:

Dim i, t, j As Integer
Dim a(10) As Integer
For j = 1 To 10
a(j) = Rnd() * 101
Next
For i = 1 To 10
For j = 1 To 10 - i
If a(j) > a(j + 1) Then
t = a(j)
a(j) = a(j + 1)
a(j + 1) = t
End If
Next
Next
For j = 1 To 10
Label1.Text += a(j).ToString + vbCrLf
Next