...函数产生20个[1, 9]区间的随机整数并存入一维数组x中?
发布网友
发布时间:2024-10-03 20:51
我来回答
共1个回答
热心网友
时间:2024-10-09 09:15
Text1.Text = ""
Dim A(1 To 20) As Integer, I As Integer
For I = 1 To 20
Randomize
A(I) = Int(Rnd * 9 + 1) '生成20个随机数,存储到数组
Next I
For I = 1 To 20
If I Mod 5 = 0 Then
Text1.Text = Text1.Text & "A(" & I & ") =" & A(I) & vbCrLf
Else
Text1.Text = Text1.Text & "A(" & I & ") =" & A(I) & Space(3) '显示已经存储到数组的随机数
End If
Next I