更多"以下程序的执行结果是______。 #include <iostre"的相关试题:
[单项选择]以下程序执行后的输出结果是( )。
#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. 不确定
[填空题]以下程序的输出结果是 【10】 。
#include <iostream>
using namespace std;
int main( )
char S[ ]="abcdef";
s[3]=’\0’;
cout<<s<<end1;
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;
[单项选择]有以下程序,其输出结果是( )。
#include <iostream>
using namespace std;
int main( )
char a[10]=’1’,’2’,’3’,’4’,’5’,’6’,’7’,’8’,’9’,0,*p;
int i=8;
p=a+i;
cout<<p-3<<endl;
return 0;
A. 6789
B. 6
C. 789
D. ’6’
[填空题]以下程序的执行结果为 【8】 。
#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( );
[填空题]以下程序的执行结果为 【9】 。
#include<iostream>
using namespace std;
void overload(int num)
{
cout<<num<<end1;
}
void overload(char ch)
{
char c=ch+1;
cout<<c<<end1;
}
int main( )
{
overload(’X’);
return 0;
}
[填空题]下列程序输出结果是 【13】 。
include <iostream>
using namespace std;
template <typename T>
T fun(T a, T b) {return (a<=b)a:b;}
int main( )
{
cout<<fun(3,6)<<’,’<<fim(3.14F, 6.28F)<<end 1;
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. 不确定
[填空题]程序的输出结果是 【15】 。
#include <iostream>
using namespace std;
class A{
public:
A( ){a=b=2;}
A(int i,int j){a=i;b=j;}
void display( ){cout<<a<<b;}
private:
int a,b;
};
void main( ){
A m,n(4,8);
m.display( );
n.display( );
}
[填空题]程序的输出结果是 【14】 。
#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);
}
[填空题]下面程序的运行结果是 【8】
#include <iostream>
using namespace std;
int fun(int n)
{
static int m = 2;
m=m+n;
return m;
}
int main ( )
{
int a = 3, b = 4;
int x;
x = fun( a );
x = fun( b );
cout<<x<<end1;
return O;
}
[填空题]下列程序的输出结果是 【15】 。
#include <iostream>
using namespace std;
class A {
int a;
public:
A( ):a(9){}
virtual void print( ) const { cout<<a; };
};
class B: public A {
char b;
public:
B( ){b=’S’;}
void print( ) const {cout <<b;}
};
void show(A &x){ x. print( );}
int main( )
{A d1,*p;
B d2;
p=&d2;
dl1.print( );
d2.print( );
p->print( );
show(d1);
show(d2);
return 0;
}
[填空题]下列程序的输出结果是 【12】 。
#include <iostream>
using namespace std;
int main( )
{
int i=5;
int &r=i; r=7;
cout<<i<<end1;
return 0;
}
[填空题]下面程序的打印结果是 【11】 。
#include <iostream>
using namespace std;
class Base
public:
Base(int x)
a=x;
void show( )
cout<<a;
private:
int a;
;
class Derived : public Base
public:
Derived(int i) :Base(i+1) ,b(i)
void show( )
cout<<b;
private:
int b;
;
int main ( )
Base b(5) , *pb;
Derived d(1);
pb=&d;
pb->show( );
return 0;