A-A+
有以下程序:#include <stdio.h>int f1 (int x int y) {
问题详情
有以下程序:#include <stdio.h>int f1 (int x,int y) { return x > y? x :y; }int f2 (im x,int y) { return x > y? y: x; }main() int a=4,b=3,c=5,d=2,e,f,g; e=f2(f1(a,b),f1(c,d)); f=f1(f2(a,b),f2(e,d)); g=a+b+e+d-e-f; printf("% d,% d,% d n" ,e,f,g);}程序运行后的输出结果是()。
A.4,3,7
B.3,4,7
C.5,2,7
D.2,5,7请帮忙给出正确答案和分析,谢谢!
参考答案
正确答案:A
解析:函数f1的功能是返回两个数中的较大数,熳的功能是返回两个数中较小的数。具体执行过程如下:①执行f1(a,b),即f1(4,3),返回值引执行f1(c,d),即f1(5,2),返回值5;执行e=f2(f1(a,b),f1(c,d)),即f2(4,5),返回值4。②执行f2(a,b),即f2(4,3),返回值3;执行f2(c,d),即f2(5,2),返回值2;执行f=f1(f2(a,b),f2(c,d)),即f1(3,2),返回值3。③执行g=a+b+c+d+e+f,即g=7。所以,程序输出结果为4,3,7。