以下程序的输出结果是【】。include<stdio.h> main () int a[3][3] ={{1 2 9} {3 4 8} {5 6 7} }
程序,正确答案
已帮助 人
以下程序的输出结果是【 】。
include <stdio.h>
main ()
int a[3][3] ={{1,2,9},{3,4,8},{5,6,7} } ,i,s=0;
for(i=0;i<3;i++) s+ =a[i][i] + a[i][3-i-1];
pfintf("% d " ,s);
请帮忙给出正确答案和分析,谢谢!
-
正确答案:30
30 解析:当i=0时,s=0+a[0][0]+a[0][2]=10;i=1时,s=10+a[1][1]+ a[1][1]=18;i=2时,s=18+a[2][2]+a[2][0]=30。
