VB用inputbox输入10个整数,用冒泡排序法从小到大排序
1个回答
展开全部
Private Sub Command1_Click()
Dim a(10) As Integer
For i = 1 To 10
a(i) = InputBox("请输入a(" & i & "):")
Print a(i);
Next i
For i = 1 To 9
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 j
Next i
Print "排序以后:"
For i = 1 To 10
Print a(i);
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询