帮忙啊 急
在窗体上画一个名称为Command1的命令按钮,然后编写如下程序:Option Base 1
Private Sub Command1_Click()
Dim a As Variant
a=Array(1,2,3,4,5)
Sum=0
For i=1 To 5
Sum = sum+a(i)
Next i
x=Sum/5
For i =1 To 5
If a(i)>x Then Print a(i);
Next i
End Sub
程序运行后,单击命令按钮,在窗体上显示的内容是 (D)
A)1 2 B) 1 2 3 C) 3 4 5 D) 4 5
为什么选这个答案
可否解释清楚点啊
(我知道这个问题对于你们来说很简单
但千万别不屑于回答啊)
--------------------编程问答--------------------
Option Base 1 '数组下标默认从1开始
Private Sub Command1_Click()
Dim a As Variant
a=Array(1,2,3,4,5) '把 (1,2,3,4,5) 组成数组
'把 Sum 赋值为 0 ,下面这个循环结束后, Sum 的值为这五个元素的总和
Sum=0
For i=1 To 5
Sum = Sum+a(i)
Next i
x = Sum/5 'x 的值为这五个元素总和的平均值
For i =1 To 5
' 遍历数组元素, 如果 a(i) > x ,则打印到窗体上
If a(i)>x Then Print a(i);
Next i
End Sub
--------------------编程问答-------------------- Option Base 1
数组下标为1
Private Sub Command1_Click()
Dim a As Variant
a=Array(1,2,3,4,5)
Sum=0
For i=1 To 5
Sum = sum+a(i)
Next i
sum=1+2+3+4+5=15
x=Sum/5
x=3
For i =1 To 5
If a(i)>x Then Print a(i);
Next i
从1数到5,如果大于3就输出,4和5大于3
End Sub
就是如此
以后作业题自己做,这么简单的题 --------------------编程问答-------------------- If a(i)>x Then Print a(i);
这个打印语句中,a(i)后面有个 ; ,则输出后不换行。
--------------------编程问答--------------------
Option Base 1--------------------编程问答--------------------
Private Sub Command1_Click()
Dim a As Variant
a=Array(1,2,3,4,5)
Sum=0
For i=1 To 5
Sum = sum+a(i) '这里在做累加,从1加到5,结果是15.
Next i
x=Sum/5 '15除以5是多少?
For i =1 To 5
If a(i)>x Then Print a(i); 如果大于3,就输出.上面的"1,2,3,4,5"里面,有几个大于3的?
Next i
End Sub
同意楼上的,,,,,,, --------------------编程问答--------------------
Option Base 1
Private Sub Command1_Click()
Dim a As Variant
a=Array(1,2,3,4,5)
Sum=0
For i=1 To 5
Sum = sum+a(i) '这里在做累加,从1加到5,结果是15.
Next i
x=Sum/5 '15除以5是多少?
For i =1 To 5
If a(i)>x Then Print a(i); 如果大于3,就输出.上面的"1,2,3,4,5"里面,有几个大于3的?
Next i
End Sub
补充:VB , 非技术类