有以下程序: int*f(int*x,int*y) { if(*x<*y) return x; else return y; } main() { int a=7,b=8,*P,*q,*r;

admin2010-09-05  23

问题 有以下程序:    int*f(int*x,int*y)    { if(*x<*y)        return x;     else        return y;    }    main()    { int a=7,b=8,*P,*q,*r;      P=&a;      q=&b;    r=f(p,q);    print("% d,% d,% d\n",*P,*q,*r);    }    执行后的输出结果是 ______。

选项 A、7,8,8
B、7,8,7
C、8,7,7
D、8,7,8

答案B

解析 函数f是一个返回值为指针的函数,其功能是比较两个数中的最小值,并返回最小值的存储单元地址。main函数中定义了指针变量p和q,p=&a,q=&b,即*p=7,*q=8,调用函数{后r=p,所以*r=7,printf函数的输出结果为 7,8,7。
转载请注明原文地址:https://kaotiyun.com/show/LOWp777K
0

随机试题
最新回复(0)