有以下程序: #include<stdio.h> void fun(int a,int b) { int t; t=a;a=b;b=t; } main() { int c[10]={1,2,3,4,5,6,7,8,9,0},i; for(i=0;i<10;

admin2021-02-25  20

问题 有以下程序:
#include<stdio.h>
void fun(int a,int b)
{
int t;
t=a;a=b;b=t;
}
main()
{
int c[10]={1,2,3,4,5,6,7,8,9,0},i;
for(i=0;i<10;i+=2)
fun(c,c[i+1]);
for(i=0;i<10;i++)
printf("%d",c);
printf("\n");
}
程序的运行结果是(    )。

选项 A、1 2 3 4 5 6 7 8 9 0
B、2 1 4 3 6 5 8 7 0 9
C、0 9 8 7 6 5 4 3 2 1
D、0 1 2 3 4 5 6 7 8 9

答案A

解析 函数fun()属于值传参,形参的变化不会影响实参,所以函数调用结束后,数组c没有任何变化,输出结果为选项A。
转载请注明原文地址:https://kaotiyun.com/show/Imtp777K
0

最新回复(0)