A-A+
以下程序的输出结果是 void fun(int*s) { static int j=0; d
问题详情
以下程序的输出结果是 void fun(int*s) { static int j=0; do s[j]+=s[j+1]; while(j<2);} main() { int k,a[10]={1,2,3,4,5}; for(k=1;k<3;k++)fun(a); for(k=0;k<5;k++)printf("%d",a[k]);}
A.34756
B.23345
C.35745
D.12345请帮忙给出正确答案和分析,谢谢!
参考答案
正确答案:C
解析:本题考查了通过数组首地址引用数组元素的方法。第一次执行fun(a)后,a[0]=3,a[1]=5。第二次执行fun(a)时,因为static变量j保存着上次执行时的值为2,所以a[2]=7,最后数组a={3,5,7,4,5}。故正确答案为选项C)。