0
1
2
3
第1题:
下列程序的输出结果是______。
include<iostream.h>
include<string.h>
using namespace std;
void fun(const char*s,char &C) {c=s[strlen(s)/2];}
int main()
{
char str[]="ABCDE";
char ch=str[1];
fun(str,ch);
cout<<ch;
return 0;
}
第2题:
有如下程序: #include<iostream> using namespace std; class Sample{ public: Sample()<) ~Sample(){cout<<'*';} }; int main(){ Sample temp[2],*pTemp[2]; return 0; } 执行这个程序输出星号(*)的个数为( )。
A.1
B.2
C.3
D.4
第3题:
以下程序的输出结果是【 】。
include <iostream>
using namespace std;
int main()
{
char S[ ]="abcdef";
s[3]='\0';
cout<<s<<end1;
return 0;
}
第4题:
下面程序的执行结果是______。
include<iostream.h>
include<iomanip.h>
using namespace std;
void main()
{
cout<<setfill('x')<<setw(10);
cout<<"Hello"<<endl;
}
第5题:
执行如下程序后的输出结果是【 】。
include <iostream>
include <fstream>
using namespace std;
int main ( )
{
char s[25];
ofstream fl("data.txt");
f1<<"C++ Programming";
f1.close ();
ifstream f2 ("data.txt");
第6题:
有如下程序 #include <iostream> #include <iomanip> using namespace std; class MyClass { public: MyClass() { cout<<'A'; } MyClass(char c){ cout<<c; } ~MyClass(){ cout<<'B'; } }; int main( ) { MyClass p1,*p2; p2=new MyClass('X'); delete p2; return 0; } 执行这个程序屏幕上将显示输出
A.ABX
B.ABXB
C.AXB
D.AXBB
第7题:
阅读下面程序:
include<iostream>
using namespace std;
long fib(int n)
{
if ( n > 2 )
return (fib(n-1)+fib(n-2));
else
return 2;
}
int main()
{
cout<<fib(3)<<end1;
return 0;
{
则该程序的输出结果应该是【 】。
第8题:
有以下面程序:
include <iostream>
using namespace std;
long fib(int n)
{
if (n>2)
return (fib(n-1)+fib(n-2));
else
return 2;
}
int main()
{
cout<<fib(3)<<endl;
return 0;
}
则该程序的输出结果应该是【 】。
第9题:
程序的输出结果是【 】。
include <iostream>
using namespace std;
class A{
int x;
public:
A(int x=1):x(x){cout<<x;}
};
void main(){
A a,b(2),c(3);
}
第10题:
有下列程序:
include<iostream>
using namespace std;
class TestClass1
{
public:
TestClass1(){cout<<"A";}
};
class TestClass2<public:TestClass2(){cout<<"B";}
};
class TestClass3:public TestClass1{
TestClass2 b;