vb程序编写题 随机产生20到80之间的10个整数,将它们从小到大排序
展开全部
Private Sub Command1_Click()
Dim MyValue(10) As Integer
Dim i, j, p As Integer
For i = 0 To 9
Randomize
MyValue(i) = Int(Rnd() * (80 - 20 + 1)) + 20
Next
For i = 0 To 9
For j = i + 1 To 10
If MyValue(i) > MyValue(j) Then
p = MyValue(i)
MyValue(i) = MyValue(j)
MyValue(j) = p
End If
Next
Next
For i = 0 To 9
Print MyValue(i)
Next i
End Sub
Dim MyValue(10) As Integer
Dim i, j, p As Integer
For i = 0 To 9
Randomize
MyValue(i) = Int(Rnd() * (80 - 20 + 1)) + 20
Next
For i = 0 To 9
For j = i + 1 To 10
If MyValue(i) > MyValue(j) Then
p = MyValue(i)
MyValue(i) = MyValue(j)
MyValue(j) = p
End If
Next
Next
For i = 0 To 9
Print MyValue(i)
Next i
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询