一。你要说明你要用的编程语言二。可以不用数组以下是VB的参考(数组a(i)可直接用一个变量代替的)Private Sub Command1_Click()Dim a(20) As Integer, s As IntegerRandomize For i = 1 To 20 a(i) = Int(Rnd * 61) If a(i) > 30 Then s = s + a(i) Next Print sEnd Sub
使用VB6实现代码,供参考。Private Sub Command1_Click() Dim a(1 To 20) As Integer, i As Integer, j As Integer, k As Integer Randomize Timer Do j = Int(61 * Rnd) i = i + 1 a(i) = j If j > 30 Then k = k + j Loop Until i = 20 Print kEnd Sub