一个高中程序类数学题:编写一个程序,实现任意输入3个实数,输出这三个数中的最小数.
2019-04-14
一个高中程序类数学题:编写一个程序,实现任意输入3个实数,输出这三个数中的最小数.
优质解答
一、求最小数
Dim a(0 To 2)
For i = 0 To 2
a(i) = InputBox("输入第" & i & "个数",,0)
Next
Min = a(0)
For i = 1 To 2
If Min > a(i) Then Min = a(i)
Next
MsgBox "最小的数是" & Min
二、求最大数
Dim a(0 To 2)
For i = 0 To 2
a(i) = InputBox("输入第" & i & "个数",,0)
Next
Max = a(0)
For i = 1 To 2
If Max < a(i) Then Max = a(i)
Next
MsgBox "最大的数是" & Max
一、求最小数
Dim a(0 To 2)
For i = 0 To 2
a(i) = InputBox("输入第" & i & "个数",,0)
Next
Min = a(0)
For i = 1 To 2
If Min > a(i) Then Min = a(i)
Next
MsgBox "最小的数是" & Min
二、求最大数
Dim a(0 To 2)
For i = 0 To 2
a(i) = InputBox("输入第" & i & "个数",,0)
Next
Max = a(0)
For i = 1 To 2
If Max < a(i) Then Max = a(i)
Next
MsgBox "最大的数是" & Max