输入十个数字 输出这十个数并输出最大值。用VB做,高一
1个回答
展开全部
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
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 "最大数是:" & a(1)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询