vb计算题:定义一个有10个元素的数组
,用随机函数Rnd给每个元素赋60~100之间的值,然后求数组中的最小值及其下标.(用循环实现)...
,用随机函数Rnd给每个元素赋60~100之间的值,然后求数组中的最小值及其下标.(用循环实现)
展开
1个回答
展开全部
Private Sub Command1_Click()
Randomize
Dim a(9) As Integer
Dim min As Integer, minI As Integer
For i = 0 To 9
a(i) = Int(Rnd() * (100 - 60 + 1)) + 60
If min < a(i) Then
min = a(i)
minI = i
End If
Next
Print "数组下标为" & minI; "的数字最小,为:" & min
End Sub
Randomize
Dim a(9) As Integer
Dim min As Integer, minI As Integer
For i = 0 To 9
a(i) = Int(Rnd() * (100 - 60 + 1)) + 60
If min < a(i) Then
min = a(i)
minI = i
End If
Next
Print "数组下标为" & minI; "的数字最小,为:" & min
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询