就一个问题,运行后J 没发生循环,即没从1加到N,搞不清楚原因,哪位达人指点下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n, i, j, k As Integer, a(100), b, c As Single
n = InputBox("n=")
For i = 1 To n
a(i) = InputBox("the" & i & "is")
Next
For j = 1 To n
For k = j + 1 To n
b = a(j)
c = j
If a(j) <= a(k) Then
Else
Exit For
End If
b = a(k) : j = k
Next
Next
a(c) = a(1)
a(1) = b
MessageBox.Show("a(1)=" & a(1) & "最小数在第" & c & "个")
End Sub