下面程序的输出结果是【 】。 #include <iostream> using namespace std; int d=1; fun(int p){ static int d = 5; d+ =p;

admin2009-01-15  22

问题 下面程序的输出结果是【  】。
   #include <iostream>
   using namespace std;
   int d=1;
   fun(int p){
       static int d = 5;
       d+ =p;
       cout<<d;
       return (d) ;
   }
   void main ( ) {
       int a =3;
       cout<<fun ( a + fun (d)  )<<endl;
   }

选项

答案61515

解析 先调用fun(d),d=1执行,局部静态变量d的值为6,输出6,返回值为6;再调用 fun(a+fun(d)),即fun(9)执行,静态局部变量的值为15,输出15,返回值为15;最后再执行 main方法中的输出语句,输出fun(a+fun(d))的值15。所以程序输出结果为61515。
转载请注明原文地址:https://kaotiyun.com/show/cZkp777K
0

相关试题推荐
随机试题
最新回复(0)