编写如下程序: Private Sub Form_Click() Dim a(5) As Integer, b(3) As Integer Dim k As Integer k = 1 For i = 1 To 5

admin2015-09-23  25

问题 编写如下程序:
Private Sub Form_Click()
    Dim a(5) As Integer, b(3) As Integer
    Dim k As Integer
    k = 1
    For i = 1 To 5
        a(i) = i
    Next i
    For i = 1 To 3
        b(i) = 2 * a(i)
    Next i
    For i = 1 To 3
        k = k + b(i) * 2
    Next i
    Print k
End Sub
运行程序,单击窗体,输出结果是

选项 A、31
B、32
C、25
D、30

答案C

解析 通过For循环,对整型数组a和b分别赋值,a=[1,2,3,4,5],b=[2,4,6],k是在原值基础上再加b每个元素值得两倍,故k=1+2*2+4*2+6*2=25,故选C项。
转载请注明原文地址:https://kaotiyun.com/show/XQLp777K
0

最新回复(0)