[单项选择题] 下列程序段的执行结果为 Dim A(3,3) For M=1 To 3 For N=1 To 3 If N=M Or N=3-M+1 Then A(M,N) =1 Else A(M,

21 查阅

[单项选择题] 下列程序段的执行结果为 Dim A(3,3) For M=1 To 3 For N=1 To 3 If N=M Or N=3-M+1 Then A(M,N) =1 Else A(M,N) =0 End If Next N Next M For M=1 To 3 For N=1 To 3 Print A(M,N) Next N Print Next M A) 1 0 0  0 1 00 0 0 B) 1 1 1 1 1 1 1 1 1 C) 0 0 0 0 0 0 0 0 0 D) 1 0 1 0 1 0 1 0 1

A. 1 0 0  0 1 00 0 0

B. 1 1 1 1 1 1 1 1 1

C. 0 0 0 0 0 0 0 0 0

D. 1 0 1 0 1 0 1 0 1

参考答案:

D

题中以嵌套For循环为数组A(3,3)赋值,此过程中,如果A(M,N)符合条件"N=M OR N=3-M+1"则此项赋1,否则赋0。以A(1,1)为例,由于M=N=1,故A(1,1)=1。 依次类推: A(1,1) =1 A(2,1) =0 A(3,1) =1 A(1,2) =0 A(2,2) =1 A(3,2) =0 A(1,3) =1 A(2,3) =0 A(3,3) =1

计算机考试