VB编写以下程序: 随机产生20个100以内的正整数,按从小到大的顺序输出在窗体上,每行打印5个。

2024-11-29 05:37:15
推荐回答(1个)
回答(1):

Private Sub Command1_Click()
Dim arr(1 To 20)
For i = 1 To 20
arr(i) = Int(Rnd * 99) + 1
Next
For i = 1 To 20
For j = i + 1 To 20
If arr(j) < arr(i) Then
a = arr(j)
arr(j) = arr(i)
arr(i) = a
End If
Next
Next
Print Join(arr)
End Sub