有點明白了,我以前也寫過這樣的程式碼,程式碼有通用性,可以求解此類問題:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A(3, 5) As Integer A(1, 1) = 5 A(1, 2) = 6 A(1, 3) = 4 Dim intMaxInt As Integer = intMax(A(1, 1), A(1, 2)) Dim i As Integer For i = 1 To 3 intMaxInt = intMax(intMaxInt, A(1, i)) Next MessageBox.Show("陣列最大值為" & intMaxInt.ToString) For i = 1 To 3 If A(1, i) = intMaxInt Then MessageBox.Show("最大值所對應的二維下標是" & i.ToString) End If Next End Sub Private Function intMax(ByVal intA As Integer, ByVal intB As Integer) If intA >= intB Then Return intA Else Return intB End If End Function你在窗體上加個Button就行了我的回答望你滿意 希望給最佳答案 謝謝
有點明白了,我以前也寫過這樣的程式碼,程式碼有通用性,可以求解此類問題:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A(3, 5) As Integer A(1, 1) = 5 A(1, 2) = 6 A(1, 3) = 4 Dim intMaxInt As Integer = intMax(A(1, 1), A(1, 2)) Dim i As Integer For i = 1 To 3 intMaxInt = intMax(intMaxInt, A(1, i)) Next MessageBox.Show("陣列最大值為" & intMaxInt.ToString) For i = 1 To 3 If A(1, i) = intMaxInt Then MessageBox.Show("最大值所對應的二維下標是" & i.ToString) End If Next End Sub Private Function intMax(ByVal intA As Integer, ByVal intB As Integer) If intA >= intB Then Return intA Else Return intB End If End Function你在窗體上加個Button就行了我的回答望你滿意 希望給最佳答案 謝謝