有以下程序: #include int fun(int x,int y) { if(x!=y)return((x+y)/2); else return(x); } main() { int a=4,b=5,c=6; pfinff("%d\n",fun(

admin2015-07-30  18

问题 有以下程序:
#include
int fun(int x,int y)
{  if(x!=y)return((x+y)/2);
else return(x);
}
main()
{  int a=4,b=5,c=6;
pfinff("%d\n",fun(2*a,fun(b,c)));
}
程序运行后的输出结果是(    )。

选项 A、6
B、3
C、8
D、12

答案A

解析 本题中第一次调用为fun(8,fun(5,6)),因为fun(5,6)返回值为5,所以第二次调用为fun(8,5)=6。所以选择答案A。
转载请注明原文地址:https://kaotiyun.com/show/xsDp777K
0

最新回复(0)