单项选择题

若有以下程序:
#include <iostream>
using namespace std;
int f()
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+=f();
cout<<a<<endl;
return 0;
程序运行后,输出的结果是

A.20
B.24
C.25
D.15
<上一题 目录 下一题>
热门 试题

单项选择题
有如下程序: #include <iostream.h> #include <iomanip.h> using namespace std; class CSum int x,y; public: CSum (int x0,int y0):x(x0),y(y0) friend ostream & operator<<(ostream& os,const CSum& x
A.

&nbs
单项选择题
有以下程序 #include <iostream> #include <string> using namespace std; class base private: char baseName[10]; public: base () strcpy(baseName, Base ); virtual char *myName() return baseName; char *className() return baseName; ; class Derived : public base private: char derivedName[10]; public: Derived() strcpy(derivedName, Derived ); char *myName() return derivedName; char *className() return derivedName; ; void showPtr(base &p) cout<<p.myName () << <<p.className (); int main () base bb; Derived dd; showPtr(dd); return 0; 运行后的输出结果为
A.Derived Base
B.Base Base
C.Derived Derived
D.Base Derived
相关试题
  • 以下程序的输出结果是 #include <iostr...
  • 有如下的程序: #include <cstring.h...
  • 有如下程序: #include <iostream> v...
  • 有以下程序: #include <iostream> u...
  • 下列类的定义中,有( )处语法错误。 cl...