3个数排序

来源:互联网 发布:云计算阅读答案 编辑:程序博客网 时间:2024/06/02 06:07
Private Sub Command1_Click()
Cls
Me.Font.Size = 24
Dim a As Integer
Dim b As Integer
Dim c As Integer

a = Int(Rnd * 1000)
b = Int(Rnd * 1000)
c = Int(Rnd * 1000)

If a < b Then
Call swap(a, b)
End If
If a < c Then
Call swap(a, c)
End If
If b < c Then
Call swap(b, c)
End If



Print a & "," & b & "," & c & "," & d
End Sub
Private Sub swap(x As Integer, y As Integer)
Dim temp As Integer
If x < y Then
temp = x
x = y
y = temp
End If
End Sub

0 0