输入x,y,z三个数,按从大到小的次序显示用VB程序怎么写

在给出答案之前麻烦先自己试着运行一下,谢谢!
2024-12-29 04:10:38
推荐回答(4个)
回答1:

Dim x%, y%, z%, a

Private Sub Command1_Click()
Randomize Timer
x = Int(Rnd * 100 + 1)
y = Int(Rnd * 100 + 1)
z = Int(Rnd * 100 + 1)
Print
If x < y Then
a = x
x = y
y = a
End If 'xIf y < z Then
a = y
y = z
z = a 'yEnd If
If x < y Then
a = x
x = y
y = a
End If 'xPrint Tab(5); "随机产生数字从大到小排序:"; x; y; z
End Sub

回答2:

给你个数组排序的吧
Dim a(3) As Integer
'输入你的数字
Dim temp As Integer
For j As Integer = 1 To 2
If a(j) < a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next

回答3:

Dim
x%,
y%,
z%,
a
Private
Sub
Command1_Click()
Randomize
Timer
x
=
Int(Rnd
*
100
+
1)
y
=
Int(Rnd
*
100
+
1)
z
=
Int(Rnd
*
100
+
1)
Print
If
x
<
y
Then
a
=
x
x
=
y
y
=
a
End
If
'xIf
y
<
z
Then
a
=
y
y
=
z
z
=
a
'yEnd
If
If
x
<
y
Then
a
=
x
x
=
y
y
=
a
End
If
'xPrint
Tab(5);
"随机产生数字从大到小排序:";
x;
y;
z
End
Sub

回答4:

Dim
x%,
y%,
z%,
a
Private
Sub
Command1_Click()
Randomize
Timer
x
=
Int(Rnd
*
100
+
1)
y
=
Int(Rnd
*
100
+
1)
z
=
Int(Rnd
*
100
+
1)
Print
If
x
<
y
Then
a
=
x
x
=
y
y
=
a
End
If
'x
评论
0
0
加载更多