.产生20个0~60的随机整数,放入数组a中,然后在窗体上输出这20个整数中大于30的所有整数之和。

pledge_331 |浏览1240次
收藏|2020/04/22 09:06

满意回答

2020/04/22 09:25

一。你要说明你要用的编程语言二。可以不用数组以下是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

whoami1978

其他回答(1)
  • 使用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
    回答于 2020/04/22 09:44
0人关注该问题
+1

 加载中...