【发布时间】:2014-08-29 07:44:30
【问题描述】:
我正在尝试实现 BubbleSort。但是,我得到一个数组越界错误;这发生在第三行。有人可以向我解释发生了什么问题吗?
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。我已经编辑了你的问题;我认为这样会更好地接受。如果您不同意编辑,您可以将其回滚。 (点击“edited ... ago”文本获取回滚菜单)。祝你好运!
标签: .net vb.net bubble-sort indexoutofrangeexception