Dim lngMaxIndex As Long
Dim i As Long
lngMaxIndex = LBound(A)
For i = LBound(A) + 1 To UBound(A)
If A(i) > A(lngMaxIndex) Then
lngMaxIndex = i
End If
Next i
A(lngMaxIndex)就是最大值
博客给出一段代码用于查找数组中的最大值。通过定义变量,利用循环遍历数组,比较元素大小,最终找到最大值所在索引,A(lngMaxIndex)即为数组A中的最大值。
Dim lngMaxIndex As Long
Dim i As Long
lngMaxIndex = LBound(A)
For i = LBound(A) + 1 To UBound(A)
If A(i) > A(lngMaxIndex) Then
lngMaxIndex = i
End If
Next i
A(lngMaxIndex)就是最大值
4428

被折叠的 条评论
为什么被折叠?