vb 如何取4 个数字 排序. 最大值 和 最小值
1.如何使用vb利用inputbox输入4个数字.分别排序由小至大2.如何使用vb利用inputbox输入4个数字取最大值和最小值...
1.如何使用vb利用inputbox 输入4 个数字 . 分别 排序 由小至大
2.如何使用vb利用inputbox 输入4 个数字 取 最大值 和 最小值 展开
2.如何使用vb利用inputbox 输入4 个数字 取 最大值 和 最小值 展开
4个回答
展开全部
Dim A(1 To 4) As Integer
Private Sub Command1_Click()
For I = 1 To 4
A(I) = InputBox("")
Next I
'开始冒泡排序
For I = 1 To 3
For J = I + 1 To 4
'冒泡原理(大的数下沉,小的数上浮)即(如果前面的大于后面的数,两者交换)
If A(I) > A(J) Then temp = A(I): A(I) = A(J): A(J) = temp
Next J
Next I
For I = 1 To 4
Print A(I)
Next
Print "max:" & A(4)
Print "min:" & A(1)
End Sub
Private Sub Command1_Click()
For I = 1 To 4
A(I) = InputBox("")
Next I
'开始冒泡排序
For I = 1 To 3
For J = I + 1 To 4
'冒泡原理(大的数下沉,小的数上浮)即(如果前面的大于后面的数,两者交换)
If A(I) > A(J) Then temp = A(I): A(I) = A(J): A(J) = temp
Next J
Next I
For I = 1 To 4
Print A(I)
Next
Print "max:" & A(4)
Print "min:" & A(1)
End Sub
2011-04-10
展开全部
Private Sub Command1_Click()
Dim a(1 To 4) As Integer
For i = 1 To 4
a(i) = InputBox("请你输入a(" & i & ")")
Next i
Max = a(1): Min = a(1)
For i = 2 To 4
If a(i) > Max Then Max = a(i)
If a(i) < Min Then Min = a(i)
Next i
For i = 1 To 3
For j = 4 To i + 1 Step -1
If a(i) > a(j) Then b = a(i): a(i) = a(j): a(j) = b
Next j
Next i
For i = 1 To 4
Print a(i)
Next
Print "max:" & Max
Print "min:" & Min
End Sub
Dim a(1 To 4) As Integer
For i = 1 To 4
a(i) = InputBox("请你输入a(" & i & ")")
Next i
Max = a(1): Min = a(1)
For i = 2 To 4
If a(i) > Max Then Max = a(i)
If a(i) < Min Then Min = a(i)
Next i
For i = 1 To 3
For j = 4 To i + 1 Step -1
If a(i) > a(j) Then b = a(i): a(i) = a(j): a(j) = b
Next j
Next i
For i = 1 To 4
Print a(i)
Next
Print "max:" & Max
Print "min:" & Min
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
x1=inputbox
x3=inputbox
x2=inputbox
x4=inputbox
if x1<x2 then
if x2<x3 then
if x3<x4 then
m=x4
else
......
msgbox "最大是" & m
...
x3=inputbox
x2=inputbox
x4=inputbox
if x1<x2 then
if x2<x3 then
if x3<x4 then
m=x4
else
......
msgbox "最大是" & m
...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim a%, b%, c%, d%, max%, min%
a = InputBox("请输入一个整数", "比较大小")
b = InputBox("请输入一个整数", "比较大小")
c = InputBox("请输入一个整数", "比较大小")
d = InputBox("请输入一个整数", "比较大小")
max = IIf(a > b, a, b)
min = IIf(a > b, b, a)
max = IIf(max > c, max, c)
min = IIf(min > c, c, min)
max = IIf(max > d, max, d)
min = IIf(min > d, d, min)
MsgBox ("最大值为" & max & vbCrLf & "最小值为" & min)
排序如果后面算法都不用的,就挨个比较吧
a = InputBox("请输入一个整数", "比较大小")
b = InputBox("请输入一个整数", "比较大小")
c = InputBox("请输入一个整数", "比较大小")
d = InputBox("请输入一个整数", "比较大小")
max = IIf(a > b, a, b)
min = IIf(a > b, b, a)
max = IIf(max > c, max, c)
min = IIf(min > c, c, min)
max = IIf(max > d, max, d)
min = IIf(min > d, d, min)
MsgBox ("最大值为" & max & vbCrLf & "最小值为" & min)
排序如果后面算法都不用的,就挨个比较吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询