vb编程,输入十个数字,找出最大值,并找出最大值的位置。
2个回答
展开全部
Private Type num
xuhao As Integer
i As Integer
End Type
Dim a(10) As num
Dim temp As num
Private Sub Command1_Click()
For i = 1 To 10
a(i).i = InputBox("请输入第" & i & "个数字")
a(i).xuhao = i
Print a(i).i
Next i
For i = 1 To 10
For j = 1 To 10 - i
If a(j).i > a(j + 1).i Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
Print "最大数字是" & a(10).i & " 位置是" & a(10).xuhao
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询