请教各位,数组中如何找第一个最大值,第二个最大值,第三个最大值?
请教各位,数组中如何找第一个最大值,第二个最大值,第三个最大值?并且返回对应的第几个元素?
[解决办法]
Private Sub Command1_Click() Dim a, b%(2), c%(2), i% a = Split("5,4,33,444,34,6,2,77,2,9,4,22", ",") For j = 0 To 2 For i = 0 To UBound(a) If a(i) > c(j) Then If b(0) <> i And b(1) <> i Then c(j) = a(i) b(j) = i End If End If Next Next Debug.Print "下标:" & b(0) & " " & b(1) & " " & b(2) Debug.Print "大数:" & a(b(0)) & " " & a(b(1)) & " " & a(b(2))End Sub
[解决办法]