[求助]如何解一个数组的应用题
题目 从键盘上任意输入4个数,并按从小到大的顺序显示出来要求用数组和inputbox
Private Sub Command1_Click()
Dim a(1 To 4) As Integer
For i = 1 To 4
a(i) = Int(InputBox(" 请输入"))
Next i
For i = 1 To 3
If a(i) > a(i + 1) Then
b = a(i)
a(i) = a(i + 1)
a(i + 1) = b
End If
Next i
For i = 2 To 4
If a(i) < a(i - 1) Then
b = a(i)
a(i) = a(i - 1)
a(i - 1) = b
End If
Next i
For i = 1 To 4
Print a(i)
Next i
End Sub
该方法还不是最好的方法,不过实用,你自己 用一下冒泡算法吧!