更多"以下程序的执行结果为【 】。
#include<iostre"的相关试题:
[填空题]以下程序的执行结果为【 】。
#include<iostream>
using namespace std;
class base
{
public:
virtual void who( )
{
cout < < "base class" < <end1;
};
class derivel:public base
{
public:
void who( )
{
cout < <"derivel class" < <end1;
};
} class derive2:public base
{
public:
void who( )
{
cout< <"derive2 class"< <end1;
}
};
void main( )
{
base obj1,* p;
derivel obi2;
derive2 obj3;
p=&obj1;
p->who( );
p=&obj2;
p->who( );
p=&obj3;
p->who( );
}
[填空题]以下程序的执行结果为 【8】 。
#include<iostream>
using namespace std;
class base
public:
virtual void who( )
cout<<"base class"<<endl;
;
class derivel:public base
public:
void who( )
cout<<"derivel class"<<endl;
;
class derive2:public base
public:
void who( )
cout<<"derive2 class"<<endl;
;
void main( )
base objl,*p;
derivel obj2;
derive2 obj3;
P=&objl;
p->who( );
p=&obj2;
p->who( );
p=&obj3;
p->who( );
[单项选择]以下程序执行后的输出结果是( )。
#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<<end1;
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. 10
D. 不确定
[填空题]以下程序执行后输出的结果是 【11】 。
#include<iostream>
using namespace std;
int fac(int a,int b)
return(b-a)*a;
int main( )
int x=3,y=4,z=5,result;
result=fac(fac(x,y),fac(x,z));
cout<<result<<endl;
return 0;
[填空题]以下程序的输出结果是 【9】 。
#include <iostream>
using namespace std;
void fun( )
{
static int a=0;
a+=2;
cout<<a;
}
int main( )
{
int CC;
for(CC=1;cc<4;CC++)
fun( );
cout<<end1;
return 0;
}
[填空题]以下程序的输出结果是 【10】 。
#include <iostream>
using namespace std;
int main( )
{
char S[ ]="abcdef";
s[3]=’\0’;
cout<<s<<end1;
return 0;
}
[单项选择]以下程序执行后的输出结果是
#include<iostream>
using namcspace 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<<end1;
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. 10
D. 不确定
[单项选择]以下程序执行后的输出结果是 #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. 10
D. 不确定
[单项选择]请选出以下程序段的输出结果 ( )。
#include <iostream>
using namespace std;
#define MIN(x,y) (x)<(y) (x) : (y)
int main ( )
int i,j,k;
i=10; j=15;
k=10*MIN(i,j);
cout<<k<<end1;
return 0;
A. 15
B. 100
C. 10
D. 150