有以下程序 #include main() { int i, s=0, t[]={1,2,3,4,5,6,7,8,9}; for(i=0;i

admin2020-03-15  20

问题 有以下程序
#include
main()
{ int i, s=0, t[]={1,2,3,4,5,6,7,8,9};
for(i=0;i<9;i+=2) s+=*(t+i);
printf("%d\n",s);
}
程序执行后的输出结果是( )。

选项 A、25
B、20
C、45
D、36

答案A

解析 数组名t为一个地址常量,表示的是数组t的首地址,所以*(t+i)与t等价,s统计的为数组t中下标为偶数的元素的和,计算结果为25,答案选A。
转载请注明原文地址:https://kaotiyun.com/show/iCCp777K
0

最新回复(0)