[单选题]

若有如下程序: include using namespaee std; int fun() { static int i=0; int s=1;

若有如下程序: #include<iostream> using namespaee std; int fun() { static int i=0; int s=1; s+=i; i++; return s; } int main() { int i,a=0; for(i=0;i<5;i++) a+=fun(); cout<<a<<end1; return 0; } 程序运行后,输出的结果是( )。

A.20

B.24

C.25

D.15

参考答案与解析:

相关试题

有如下程序: include using namespaee std; cla

[试题]有如下程序: include using namespaee std; class ONE{ public: virtual void f有如下程序:include <iostream>using namespaee std;class ONE{public:virtual void f( ){cout<<"1";}};class TWO:public ONE{public:TWO( )1 cout<<"2";}{;class THREE:public TWO{public:virtua

  • 查看答案
  • 有如下程序: include using namespaee std;class

    [单选题]有如下程序: include using namespaee std;class Animal{ public: virtual char*g有如下程序:include<iostream>using namespaee std;c lass Animal{public:virtual char*getType( )const{return"Animal";}virtual char*getVoice( )const{return"Voice";}};class Dog:public An

  • 查看答案
  • 若有如下程序:#include using namespaces std;int

    [单选题]若有如下程序:include using namespaces std;int s=0;class sample {static iht n;pu若有如下程序: #include <iostream> using namespaces std; int s=0; class sample { static iht n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=0; int main()

  • 查看答案
  • 若有如下程序:#include using namespace std;int

    [单选题]若有如下程序:include using namespace std;int main(){ char *p="abcdefgh",*r; lon若有如下程序: #include <iostream> using namespace std; int main() { char *p="abcdefgh",*r; long *q; q=(long *)p; q++; r=(char *)q; cout<<r<<end1; return 0; } 上述程序的输出结果是( )。A.abcde

  • 查看答案
  • 有如下程序:#include using namespace std;using

    [单选题]有如下程序:include using namespace std;using namespace std;class Base{public:vo有如下程序: #include <iostream> using namespace std; using namespace std; class Base{ public: void fun( ){cout<<"Base::fun"<<endl:} }; class Derived:public Base{ public: void fun(

  • 查看答案
  • 有如下程序: #include using namespace std; in

    [单选题]有如下程序: include using namespace std; int main() { char st有如下程序: #include <iostream> using namespace std; int main() { char str[100], *p; cout<<"Please input a string:"; cin>>str; p=str; for (int i=0; *p!='/0'; p++,i++); cout<<i<<endl; return 0; }

  • 查看答案
  • 有如下程序:#include £«using namespace std ;#i

    [单选题]有如下程序:#include +using namespace std ;#includeusing namespace std;class Base{public:void fun(){cout<<"Base::fun"<};class Derived:public Base{public:void fun(){cout<<"Derived::fun"<}};int main(){D.erived d;d.fun();return 0;}已知其执行后

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class BASE { public有如下程序: #include<iostream> using namespace std; class BASE { public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE { public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVEDx;retum 0;}

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class A { public:有如下程序: #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B<public:B(){cout<<"B";)); class C:public A { B b; public: C(){cout<<"C";} }; int main(){Cobj;retum 0

  • 查看答案
  • 有如下程序: #include using namespace std; int

    [单选题]有如下程序: include using namespace std; int main() { cout.f有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*') cout.width(6); cout.fill('#') cout<<123<<endl; return 0; } 执行后的输出结果是A.###123B.123###C.***123D.123***

  • 查看答案
  • 若有如下程序: #include using namespaee std; in