cout<<*arr+1<<endl;
cout<<*(arr+1)<<endl;
cout<<arr[1]<<endl;
cout<<*arr<<endl;
第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题:
以下程序的输出结果是_____。
include<iostream.h>
class object
{ private:
int val;
public:
object( ) ;
object(int i) ;
~object( ) ;};
object: :object( )
{ val=0;
cout < < "Default constructor for object" < < endl;}
object: :object(int i)
{ val=i;
cout < < "Constructor for object" < < val < < endl;}
object: :~object( )
{ cout < < "Destructor for object" < < val < < endl;}
class container{ private:
object one;
object two;
int data;
public:
container( ) ;
container(int i,int j,int k) ;
~container( ) ;};
container: :container( )
{ data=0;
cout < < "Default constructor for container" < < endl;}
container: :container(int i,int j,int k) :two(i) ,one(j)
{ data=k;
cout < < "Constructor for container" < < endl;}
container: :~container( )
{ cout < < "Destructor for container" < < endl;}
void main( )
{ container anObj(5,6,10) ;}
第4题:
已知数组arr的定义如下:
int arr[5]={1,2,3,4,5 }、
下列语句中输出结果不是2的是
A.cout<<*arr+1<<endl;
B.cout<<*(arr+1)<<endl;
C.cout<<art[1]<<endl;
D.cout<<*arr<<endl;
第5题:
以下程序的输出结果是_____。
include<iostream.h>
void fun( )
{ static int a=0;
a+=2;
cout < < a < < " ";}
void main( )
{ int cc;
for(cc=1;cc<4;cc++)
fun( ) ;
cout < < endl;}
第6题:
已知数组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;
第7题:
分析一下这段程序的输出(Autodesk)
class B
{
public:
B()
{
cout<<"default constructor"<<endl;
}
~B()
{
cout<<"destructed"<<endl;
}
B(int i):data(i) //B(int) works as a converter ( int ->
instance of B)
{
cout<<"constructed by parameter " << data <<endl;
}
private:
int data;
};
B Play( B b)
{
return b ;
}
(1) results:
int main(int argc, char* argv[]) constructed by
parameter 5
{ destructed B(5)形参析构
B t1 = Play(5); B t2 = Play(t1); destructed t1形
参析构
return 0;
destructed t2 注意顺序!
} destructed t1
(2) results:
int main(int argc, char* argv[]) constructed by
parameter 5
{ destructed B(5)形参析构
B t1 = Play(5); B t2 = Play(10); constructed by
parameter 10
return 0;
destructed B(10)形参析构
} destructed t2 注意顺序!
destructed t1
第8题:
有以下程序
main( )
{ int a=5,b=4,c=3,d=2;
if(a>b>c)
cout<<d<<endl;
else if((c-1>=d)==1)
cout<<d+1<<endl;
else
cout<<d+2<<endl;
}
执行后输出结果是
A.2
B.3
C.4
D.编译时有错,无结果
第9题:
有如下类定义和变量定义: class Parents{ public: int publicData: private: int privateData; }; class ChildA:public Parents{/类体略*/}; class ChildB:private Parents{/类体略*/}; ChildA a; ChildB b; 下列语句中正确的是
A.cout<<a.publicData<<endl;
B.cout<<a.privateData<<endl;
C.cout<<b.publieData<<endl;
D.eout<<b.privateData<<endl;
第10题:
有如下程序: #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”<<endl: } test( ){Cout<<”destruCtor”<<endl;} }; int main( ){ test A(3); return 0; } 执行这个程序的输出结果是( )。
A.3
B.ConstruCtor destruCtor
C.Copy ConstruCtor destruCtor
D.3 destruCtor
第11题:
下列程序执行后的输出结果是 #include<string.h> main() { char arr[2][4]; strcpy(arr, "you"); strcpy(arr[1], "me"); arr[0][3]='&'; cout<<arr<<endl; }
A.you&me
B.you
C.me
D.err
第12题:
以下语句中,输出结果与众不同的一个是()
第13题:
#include <iostream>using namespace std;struct student_info{ string name; int chinese; int math; int english;};student_info student[5];void inputinfo(){ int i = 0; char a[20]; for(i = 0;i < 5;i++) { cout<<"enter the "<<i+1<<" student's information "<<endl; cout<<"enter the name"<<endl; cin>>a; student[i].name = a; cout<<"enter chinese performance :"<<endl; cin>>student[i].chinese; cout<<"enter math performance :"<<endl; cin>>student[i].math; cout<<"enter english performance :"<<endl; cin>>student[i].english; }}void outputinfo(){ int i = 0; while(i < 5) { cout<<i+1<<" student's information"<<endl; cout<<student[i].name.c_str()<<endl; cout<<"chinese "<<endl; cout<<student[i].chinese<<endl; cout<<"math "<<endl; cout<<student[i].math<<endl; cout<<"english "<<endl; cout<<student[i].english<<endl; i++; }}int avgfunction(int arr[],int n){ int i = 0; int total = 0; for(i = 0;i < n;i++) { total += arr[i]; } return total / n;}void computavg() //这里是否正确?{ int theavg = 0; theavg = avgfunction(student[i].chinese,5); }int main(){ inputinfo(); outputinfo(); computavg(); cin.get(); return 0;} 帮我找出错误 然后改过来 择优为满意答案 不分先后
第14题:
有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*') cout.width(6); cout.fill('#') cout<<123<<endl; return 0; } 执行后的输出结果是
A.###123
B.123###
C.***123
D.123***
第15题:
下列程序的输出结果是( )。 #ificlude<iostream> using namespace std; int main() { cout.fill('*'); cout.width(5); cout<<oct<<100<<endl; return 0; }
A.**100
B.**144
C.100**
D.144**
第16题:
有如下程序: #include<iostream> using namespace std; int fun(int a, int b) {return(++a*b++);} void main() { int x=3,y=4,z=5,r; r=fun (fun (x,y),z); cout<<r>>endl; cout<<x<<endl; cout<<y<<endl; } 该程序的输出的结果是( )。
A.85 3 4
B.60 3 4
C.126 4 5
D.85 4 5
第17题:
下列程序中需要清理动态分配的数组,划线处应有的语句是_______。
include<iostream.h>
class person
{
int age,tall;
public:
person( ){age=0;tall=40;cout<<"A baby is born."<<endl;}
person(int i){age=i;tall=40;cout<<"A old person."<<endl;}
person(int i,int j){age=i;tall=j;cout<<"a old person with tall."<<endl;)
~person( ){cout<<"person dead."<<endl;}
void show( )
{
cout<<"age="<<age<<",tall="<<tall<<endl;
}
};
void main( )
{
person*ptr;
ptr=new person[3];
ptr[0]=person( );
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3;i++)
ptr[i].show( );
______
}
第18题:
下列程序段的输出结果是 #include<iostream.h> void fun(int * x,int * y) { cout << * X << * y; *X=3; *y=4; } void main() { int x=1,y=2; fun(&y,&x); cout << X << y<<endl; {
A.2143
B.1212
C.1234
D.2112
第19题:
下列程序的输出结果是【 】。
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;
第20题:
有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*'); cout.width(5); cout<<scientific<<315926535<<endl; retrun 0; } 程序运行后,输出的结果是( )。
A.3.14E+02
B.3.14E+02
C.**3.14e+002
D.314.16
第21题:
下列语句中,输出与众不同的是
A.cout<<"1."<<setfill('')<<"Hello!"<<endl;
B.cout<<"1."<<''<<"Hello! \n";
C.cout<<"1. Hello!"<<endl;
D.cofit<<"1."<<setw(7)<<"Hello!";
第22题:
有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*'); cout.width(5); cout<<scientific<<314.15926535<<endl; return 0; } 程序运行后,输出的结果是( )。
A.3.141593e+002
B.3.1416e+002
C.**3.14e+002
D.314.16
第23题:
有如下程序: #include<iostream> using namespace std; long fib(int n) { if(n>2) return(fib(n-1)+fib(n-2)); else return(n); } void main() { int i; cout<<"请输入一个整数:"; cin>>i;cout<<endl; cout<<fib(i)<<endl; { 当输入4、2时,该程序的输出结果是( )。
A.5
B.4
C.5
D.6 1 2 2 2