更多"下列程序的输出结果是( )。 #include<iostrea"的相关试题:
[填空题]下面程序的输出结果是 【15】 。
#include<iostream>
using namespace std;
class base
{
protected:
int a;
public:
base( ){cout<<"0":}
};
class base1:virtual public base
{
public:
base1( ){cout<<"1";}
};
class base2:virtual public base
{
public
base2( ){cout<<"2";
};
class derived:public base1,public base2
{
public:
derived( ){cout<<"3";}
}
int main( )
{
derived obj;
cout<<end1;
return 0;
}
[填空题]下列程序的输出结果是 【10】 。
#include<iostream>
using nameSpace std;
int main( )
{
int data=1;
int &r=data;
data+=5;
r+=5;
cout<<data<<end1;
return 0;
}
[填空题]下列程序的输出结果是 【11】 。
#inClude<iostream>
using namespace std;
class Test {
public:
Test( ) {cnt++;}
~Test( ){cnt--;}
static int Count( ) {return cnt;}
private:
static int cnt;
};
int Test::cnt=0;
int main( )
{
cout<<Test::Count( )<<”;
Test t1,t2;
Test*pT3=new Test;
Test*pT4=new Test;
cout<<Test::Count( )<<’’;
delete pT4;
delete pT3;
cout<<Test::Count( )<<endl;
return 0;
}
[填空题]下列程序的输出结果是 【10】 。
#inClude<iostream>
using namespace std;
int main( )
{
int i=5;
int &r=i;r=7;
cout<<i<<endl;
return0;
}
[填空题]执行这个程序的输出结果是( );
#include<iostream>
using namespace std;
class TestClass1
{
public:
void fun1( ){cout<<"TestClass1/n";}
virtual void fun2( ){cout<<"TestClass1/n";}
};
class TestClass2:public TestClass1
{
public:
void fun1( ){cout<<"TestClass2/n";}
void fun2( ){cout<<"TestClass2/n";}
};
void f(TestClass1&b){b.fun1( );b.fun2( );}
int main( )
{
TestClass2 obj;
f(obj);
return 0;
}
[单项选择]执行下面程序后输出的结果是( )。
#include <iostream>
using namespace std;
int main( )
int a[4][4]=1,2,3,-4,7,-12,-13,8,-21,9,0,-24,-31,10,-33,11;
int i,j,s=0;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(a[i][j]>=0)continue;
s+=a[i][j];
coat<<s<<endl;
return 0;
A. 141
B. -138
C. -1
D. 75
[单项选择]以下程序执行后的输出结果是( )。
#include <iostream>
using namespace std;
void try(int,int,int,int);
int main( )
int x,y,z,r;
x=1;
y=2;
try(x,y,z,r);
cout<<r<<endl;
return 0;
void try(int x,int y,int z,int r)
z=x+y;
x=x*x;
y=y*y;
r=z+x+y;
A. 18
B. 9
C. 不确定
[填空题]下列程序的输出结果是______。
#include<iostream>
using namespace std;
Class Test{
public:
Test( ){cnt++;}
~Test( ){cnt--;}
static int Count( ){return cnt;}
private:
static int cnt;
};
int Test::cnt=0;
int main( )
{
cout<<Test::Count( )<<"";
Test t1,t2;
Test*pT3=new Test;
Test*pT4=new Test;
cout<<Test::Count( )<<"";
delete pT4;
delete pT3;
cout<<Test::Count( )<<end1;
return 0;
}
[填空题]下面程序的运行结果是 【9】 。
#include <iostream>
using namespace std;
void fun(int &a, int b=3)
{
static int i=2;
a = a + b + i;
i = i + a;
}
int main( )
{
int x=5, y=2;
fun(x, y);
cout<<x<<",";
fun(x);
cout<<x<<end1;
return 0;
}
[单项选择]执行以下程序后的输出结果为( )。
#include <iostream>
Using namespace std;
void fun(int x,int y,int *cp,int *dp)
*cp=x+y;*dp=x-y;)
void main( )
int a,b,c,d;
a=30; b=50;
fun(a,b,&c,&d);
cout>>c>>','<<d<<endl;
A. 50,30
B. 30,50
C. 80,-20
D. 80,20
[填空题]下面程序的运行结果是______。
#include<iostream>
using namespace std;
class count
{
static int n;
public:
count( )
{
n++;
}
static int test( )
{
for(int i=0;i<4;i++)
n++;
return n;
}
};
int count::n=0;
int main( )
{
cout<<count:: test( )<<" ";
count c1, c2;
cout<<count :: test( )<<endl;
return 0;
}
[单项选择]下列程序执行后,屏幕的输出是( )。
#include<iostream>
using namespace std;
void swap(int x,int y)
int temp=x;
x=y;
y=temp;
cout<<"x="<<x<<"",y=""<<y<<end1;
int main( )
int x=3,y=2;
swap(x,y);
cout<<"x="<<x<<",y="<<y<<end1;
return 0;
A. x=3,y=2
B. x=2,y=3
C. x=2,y=3
D. x=3,y=2
[单项选择]以下程序输出结果是( ):
#include<iostream>
using namespace std;
void add(int x,int y,int *z)
*z=y+x;
int main( )
int a,b,c;
add(8,4,&a);
add(6,a,&b);
add(a,b,&c);
cout<<a<<","<<b<<","<<c<<end1;
return 0;
A. 12, 10, 14
B. 12, 18, 30
C. 12, 6, 18
D. 12, 14, 30
[单项选择]下列程序的输出结果是
#include"iostream"
using namespace std;
int Max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
void main( )
{
int m,n;
m=10,n=5;
int max=Max(m,n);
cout<<max<<endl;
}
A. 10
B. 程序有误
C. 1
D. 0
[单项选择]下面程序输出的结果是( )。
#include <iostream>
using namespace std;
void swap(int &a,int &b)
int temp;
temp=a;
a=b;
b=temp;
void main( )
int x=2;
int y=3;
swap(x,y);
cout<<x<<y;
A. 23
B. 32
C. ab
D. ba
[单项选择]下面程序输出的结果是( )。
#include<iostream>
using namespace std;
class A
int X;
public:
A(int x):x(++x)
~A( )cout<<x;
;
class B:public A
int y;
public:
B(int y):A(y),y(y)
~B( )cout<<y;;
;
void main( )
B b(3);
A. 34
B. 43
C. 33
D. 44