有以下程序 #include <stdio.h>void exch(int t[ ]){ t[0]=t[5]; }main() { int x[10]={1
程序
已帮助 人
有以下程序
#include <stdio.h>
void exch(int t[ ])
{ t[0]=t[5]; }
main()
{ int x[10]={1,2,3,4,5,6,7,8,9,10),i=0;
while(i<=4){ exch(&x[i]); i++; }
for(i=0; 1<5;i++) printf(”%d",x[i]);.
printf("\n");
}
程序运行后输出的结果是
A) 2 4 6 8 10
B) 1 3 5 7 9
C) 1 2 3 4 5
D) 6 7 8 9 10
-
参考答案:D【答案】D【知识点】数组作为参数进行的函数调用
【解析】第一次调用将x[0]的地址作为了形参数组t的首址,使得x[0]的值变成了6。第二次调用将x[1]的地址作为了形参数组t的首址,使得x[1]的值变成了7。第三次调用将x[2]的地址作为了形参数组t的首址,使得x[2]的值变成了8。第四次调用将x[3]的地址作为了形参数组t的首址,使得x[3]的值变成了9。第五次调用将x[4]的地址作为了形参数组t的首址,使得x[4]的值变成了10。
