有以下程序: #include void f(int*P,int*q); main() { int m=1,n=2,*r=&m: f(r,&n); printf(“%d,%d”,m,n); } void

admin2017-11-06  20

问题 有以下程序:
  #include
  void f(int*P,int*q);
  main()
  {
    int m=1,n=2,*r=&m:
    f(r,&n);
    printf(“%d,%d”,m,n);
  }
    void f(int*p,int*q)
    }
    P=P+1:
    *q=*q+1:
    }
    程序的运行结果是(    )。

选项 A、2,3
B、1,3
C、l,4
D、1,2

答案B

解析 在f(int*p,int*q)函数中,执行p=p+1是将p所对应的地址加1,而*q=*q+1是将q所指向n的地址所对应的值加1,所以m的值所对应的值没有变,而n的值则为3了,因此B选项正确。
转载请注明原文地址:https://kaotiyun.com/show/HBxp777K
0

最新回复(0)