实现上述功能的VB程序如下,但加框处代码有错,请改正。
Const n = 100
Dim a(1 To n)As Integer
Private Sub Form_Load( )
‘随机产生100个0到99之间的整数存数组a中,并在列表框list1中显示。
End Sub
Private Sub Command1_Click( )
Dim i As Integer, j As Integer, t As Integer
Dim b(0 To 9)As Integer, c(0 To 9)As Integer
For i = 1 To n
①
Next i
For i = 0 To 9
b(i) = i
Next i
i = 0
Do While i <= 8
For j = i + 1 To 9
If Then ②
t = b(i): b(i) = b(j): b(j) = t
t = c(i): c(i) = c(j): c(j) = t
End If
Next j
i = i + 1
Loop
List2.AddItem “范围元素个数”
For i = 0 To 9
List2.AddItem Str(b(i) * 10) + "~" + Str(b(i) * 10 + 9) + ": " + Str(c(i)) + "个"
Next i
End Sub