(25)下列程序段的输出结果是 Dim M(5,5),S(5) For i=1 To 5 S(i)=0 For j=1 To 5 M(i,j)=i+j S(i

15 查阅

(25)下列程序段的输出结果是 Dim M(5,5),S(5) For i=1 To 5 S(i)=0 For j=1 To 5 M(i,j)=i+j S(i)=S(i)+M(i,j) Next j Next i For Each x In S Print x; Next xA.20 23 24 35 40 B.20 25 30 35 40 C.20 23 25 35 40 D.20 25 35 40 45

参考答案:

B【解析】程序的执行过程是:当i=1时,j=1,M(1,1)=i+j=2;S(1)=S(1)+M(1,1)=2。当j=2时,M(1,2)=i+j=3;S(1)=S(1)+M(1,2)=5。当j=3时,M(1,3)=i+j=4;S(1)=S(1)+M(1,3)=9。当j=4时,M(1,4)=i+j=5;S(1)=S(1)+M(1,4)=14。当j=5时,M(1,5)=i+j=6;S(1)=S(1)+M(1,5)=20。依此类推,最后S数组元素的值为:S(1)=20;S(2)=25;S(3)=30;S(4)=

计算机二级