有以下程序 #include <stdio.h> int fun (int x, int y ) { if (x!=y) return ( (x+y) /2 ); else return

admin2020-10-26  12

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

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

答案B

解析 fun函数的功能是获取二个数的平均数,注意平均数是整型数,小数会被截断。fun(2*4,fun(5,6)):fun(8,5):6,因此答案为C选项
转载请注明原文地址:https://kaotiyun.com/show/u33p777K
0

最新回复(0)