有个低级问题想请教
Private Sub Form_Click()Dim a(10) As Integer, i As Integer
Randomize
i = 0
Do
num = Int(Rnd * 90) + 10
For j = 1 To i
If num = a(j) Then
Exit For
End If
Next j
If j > i Then
i = i + 1
a(i) = num
End If
Loop While i < 10
For i = 1 To 9
For j = i + 1 To 9
If a(i) > a(j) Then temp = a(i): a(i) = a(j): a(j) = temp
Next j
Next i
For i = 1 To 10
Print a(i)
Next i
End Sub
这是个随机数生成并排序的代码,然而有一句怎么读都读不懂
Do
num = Int(Rnd * 90) + 10
For j = 1 To i
If num = a(j) Then
Exit For
End If
Next j
If j > i Then
i = i + 1
a(i) = num
End If
Loop While i < 10
这句中按第一次运行可以得出a(1)的值,而当第二次循环时发现 if J>i Then后面的运行是不可行的,因此应该不能进行i的递增,也就应该成为死循环了。但在VB中运行时却可以进行循环,这个问题请各位大神指点下。本人新手多多指教