单项选择题

若有以下程序:
#include<iostream>
using namespace std;
int f()

static int i=O;
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;
retrun 0;

程序运行后,输出的结果是

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

单项选择题
有以下程序: class Date public: Date(int y,int m,int D) ; year =y; month=m; day=d; Date(int y=2000) year=y; month=10; day=1; Date(Date &D) year=d.year; month=d.month; day=d.day; void print () cout<<year<< . <<month<< . <<day<<end1; private: int year,month,day; ; Date fun(Date D) Date temp; temp=d; return temp; int main() Date date1(2000,1,1),date2(0,0,0); Date date3(date1); date2=fun(date3); return 0; 程序执行时,Date类的拷贝构造函数被调用的次数是
A.2
B.3
C.4
D.5
单项选择题
以下程序段共有错误( )处。 #include <iostream> using namespaces std; class Sample private: int n; public: Sample(int i) n=i; void setvalue (int i) n=i; void display() cout<<”n=”<<n<<endl; ; int main() const Sample a(10); a.setvalue(5); a.display(); return 0;
A.1
B.2
C.3
D.4
相关试题
  • 已知int DBL(int n)return n+n;和lo...
  • 有如下程序: #inClude<iostream> usi...
  • 有以下面程序: #include<iostream> u...
  • 有以下程序 #include<iostream> using...
  • 下列程序的输出结果是 【10】 。 #in...