输入十个数字 输出这十个数并输出最大值。用VB做,高一
发布网友
发布时间:2024-10-23 15:11
我来回答
共1个回答
热心网友
时间:2024-10-24 11:57
Private Sub Command1_Click()
Dim a(1 To 10) As Single
For i = 1 To 10
'a(i) = Val(InputBox("请输入第" & i & "个数", "第" & i & "个数")) '方法1,一个一个输入
Randomize
a(i) = Int(Rnd * 999 + 1) '方法2 ,随机生成100-999的10个整数,现在是使用这个方法
Next i
Print "这十个数是:"
For i = 1 To 10
Print a(i);
Next i
Print
For i = 1 To 9
For j = 1 To 10 - i
If a(j) < a(j + 1) Then a(j) = a(j + 1)
Next j
Next i
Print
Print "最大数是:" & a(1)
End Sub