-1
我正在嘗試實現BubbleSort。但是,我得到一個數組越界的錯誤;這發生在第三行。有人可以向我解釋發生了什麼事嗎?冒泡排序和IndexOutOfRangeException
For i As Integer = 0 To marks.Length Step 1
For x As Integer = 0 To marks.Length - 1 Step 1
If marks(x) > marks(x + 1) Then <<< "this where the problem is"
temp = marks(x + 1)
marks(x + 1) = marks(x)
marks(x) = temp
End If
Next x
Next i
For a As Integer = 0 To marks.Length
MsgBox(marks(a))
Next
歡迎來到Stack Overflow。我編輯了你的問題;我認爲這樣會更好地收到。如果您不同意編輯,則可以將其回滾。 (單擊「編輯...之前」文本以獲取回滾菜單)。祝你好運! – 2014-08-29 08:07:22