一个20个元素的数组。随机所有元素并排序 vb编写
展开全部
Private Sub Command1_Click()
Randomize
Dim a(20) As Integer
For i = 1 To 20
a(i) = Int(Rnd * 101 + 100)
Print a(i);
Next i
For i = 1 To 20
For j = 1 To 20 - i
If a(j) > a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
For i = 1 To 20
Print a(i);
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询