24
12
9
6
第1题:
有如下程序:#include<iostream>using namespace std;class test{private: int a;public: test(){cout<<"constructor"<<endl;} test(int a){cout<<a<<endl;} test(const test&_test) { a=_test.a; cout<<"copy constructor"<<en+dl; } ~test(){cout<<"destructor"<<endl;}};int main(){ test A(3); rerun 0;}运行时输出的结果是
A.3
B.constructor destructor
C.copy constructor destructor
D.3 destructor
第2题:
已知数组arr的定义如下: intarr[5]={1,2,3,4,5};下列语句中输出结果不是2的是( )。
A.cout<<*arr+1<<endl;
B.COUt<<*(art+1)<<endl;
C.cout<<arr[1]<<endl;
D.COUt<<*arr<<endl:
第3题:
( 27 )有如下程序:
#include
using namespace std;
class test {
private:
int a;
public:
test () {cout<< ” constructor ” <<ENDL;}
test ( int a ) {cout<<A<<ENDL;}
test ( const test & _test )
{
a=_testa;
cout<< ” copy constructor ” <<ENDL;
}
test () {cout<< ” destructor ” <<ENDL;}
};
int main ()
}
test A ( 3 )
return0;
运行时输出的结果是
A ) 3
B ) constructor
destruclor
C ) copy constructor
dstructor
D ) 3
destruclor
第4题:
下列程序的输出结果是【 】。
include<iostream.h>
void main()
{
int i(1),j(2),k(3),a(10);
if(!i)
a--;
else if(j)
if(k)a=5;
else
a=6;
a++;
cout<<a<<endl;
if(i<j)
if(i!=3)
if(!k)
a=1;
else if(k)
a=5;
6+=2;
cout<<a<<endl;
第5题:
已知数组arr的定义如下: int arr[5]={1,2,3,4,5}; 下列语句中,输出结果不是2的是
A.cout<<*arr+1<<endl;
B.tout<<*(arr+1)<<endl;
C.cout<<arr[1]<<endl;
D.eout<<%arr<<endl;
第6题:
语句cout<<setiosflagags(ios::showpos)<<125<<"/t"<<-125<<endl;的输出结果为【 】。
第7题:
下面程序运行输出的结果是【 】。
include <iostream>
using namespace std;
int main(){
char a[]="Chinese";
a[3]='\0';
cout<<a<<endl;
return 0;
}
第8题:
( 20 )已知数组 arr 的定义如下:
int arr[5] = {1,2,3,4,5};
下列语句中输出结果不是 2 的是
A ) cout << *arr+1 <<endl;
B ) cout << *(arr+1)<<endl;
C ) cout << arr[1] <<endl;
D ) cout << *arr <<endl;
第9题:
若有如下变量定义和函数调用语句: inta=5; fun(&A) ; 则执行下面函数后正确的输出结果是( )。 void fun(int*x) { cout<<++*x<<endl; }
A.3
B.4
C.5
D.6
第10题:
以下三条输出语句分别输出什么?
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha << ( str1==str2 ) << endl; // 输出什么?
cout << boolalpha << ( str3==str4 ) << endl; // 输出什么?
cout << boolalpha << ( str5==str6 ) << endl; // 输出什么?