下列程序的输出结果是______。 long fun5(int n) ( long s; if((n==l)‖(n==2)) s=2;

admin2013-06-11  22

问题 下列程序的输出结果是______。
        long fun5(int n)
        (   long s;
              if((n==l)‖(n==2))
                   s=2;
              else
                   s=n+fun5(n-1);
              return(s);
     }
        main()
              {   long x;
              x=fun5(4);
              printf(%1d\n",x);

选项

答案9

解析 考查if else语句,n==4不满足条件,所以fun5(4)=4+fun5(3),n==3也不满足条件,fun5(3)=3+fun5(2),n==2满足条件fun5(2)=2,故x=4+3+2=9。
转载请注明原文地址:https://kaotiyun.com/show/PjJp777K
0

最新回复(0)