下列程序的执行结果是( )。 Private Sub Form Activate0 Dim score(3)As Integer,total As Integer Dim aa_scoreAsVariant s

admin2012-09-07  19

问题 下列程序的执行结果是(    )。
    Private Sub Form Activate0
    Dim score(3)As Integer,total As Integer
    Dim aa_scoreAsVariant
        score(1)=50:score(2)=14:score(3)=36
        total=0:i=0
        For Each aa_score In score
            i=i+1
            total=total+aa_score
            Print i,aa_score total
        Next
    End Sub

选项 A、l 0 0
    2 50 50
    3 14 64
    4 36 100
B、1 50 50
    2 14 64
    3 36 100
C、0 50 50
    1 14 64
    2 36 100
    3 36 100
D、0 0 0
    1 50 50
    2 14 64
    3 36 100

答案A

解析 本题考查For Each In语句。该语句的使用形式为:For Each成员In数组…Next,适用于不关心数组中的元素个数或者不清楚有多少个元素,使用时要求成员为变体类型变量。当激活窗体时,对score数组中的每个元素进行求和,同时i记下当前计算数组元素的个数。默认数组下标从0开始,题中score数组中含有4个元素,输出4行。
转载请注明原文地址:https://kaotiyun.com/show/oRhp777K
0

最新回复(0)