有以下程序: #include <stdio.h> void f(int y,int *x) { y=y+ *x; *x=*x+y;} main() { int x=2,y=4; f(y,&x);

admin2013-02-23  18

问题 有以下程序:
   #include  <stdio.h>
   void f(int y,int *x)
   {  y=y+ *x; *x=*x+y;}
   main()
   {  int x=2,y=4;
      f(y,&x);
      printf("%d%d\n",x,Y);
   }
   执行后的输出结果【  】。

选项

答案8 4

解析 f函数中变量x传的是变量的地址,而变量y是传的值,调用函数f后,虽然f函数中的。x变为8,y值也变了,但main函数中的y未变,仍然为4。
转载请注明原文地址:https://kaotiyun.com/show/SBJp777K
0

最新回复(0)