发布网友 发布时间:2024-10-24 07:04
共3个回答
热心网友 时间:2024-10-24 08:39
当你完成
For i = 1 To 10
If a(i) > aver Then
End If
时,i=11了, a(i)下标越界
Option Base 1
Private Sub Form_Click()
Dim a(10) As Integer, aver!, sum As Integer
For i = 1 To 10
a(i) = Int(Rnd * 90 + 10)
sum = sum + a(i)
Print a(i);
If i Mod 5 = 0 Then Print
Next
aver = sum / 10
Print "平均成绩为:"; aver
For i = 1 To 10
If a(i) > aver Then Print "正整数是:"; a(i)
Next
End Sub
热心网友 时间:2024-10-24 08:40
a(10)代表的是0到9,而不是1到10.
把for i=1 to 10改为 fro i=0 to 9
热心网友 时间:2024-10-24 08:41
Option Base 1
Private Sub Form_Click()
Dim a(10) As Integer, aver, sum As Integer
For i = 1 To 10
a(i) = Int(Rnd * 90 + 10)
sum = sum + a(i)
Print a(i);
If i Mod 5 = 0 Then Print
Next
aver = sum / 10
For i = 1 To 10
If a(i) > aver Then
Print "正整数是:"; a(i)
End If
Next
Print "平均成绩为:"; aver
End Sub