更多"下列程序的输出结果是( )。 #include<iostream>"的相关试题:
[单项选择]下面程序输出的结果是( )。 #include<iostream> using namespace std; int test(int n1,int n2) {return n1 +n2;} float test (int f1,float f2){return f1-f2;} float test(float x,float y){return(x+y)/2;} float test(float x,int y){return(x+y)*2;} void main( ){ int a1=10; float a2=2.5f; cout<<test(a1,a2); }
A. 12.5
B. 7.5
C. 6.25
D. 25
[单项选择]如下程序运行时的输出结果是
#include<iostream>
using namespace std;
class ONE
int c;
public:
ONE( ):c(0)eout<<1;
ONE(int n):C(n)cout<<2;
;
class TW0
ONE onel;
ONE one2;
public:
TWO(int m):one2(m)eout<<3;
;
int main( )
TWO t(4);
return 0;
A. 3
B. 23
C. 123
D. 213
[单项选择]下面程序的输出结果是( )。
#include<iostream>
using namespace std;
void main( )
int i=1;
while(i<=8)
if(++i%3!=2)continue;
else cout<<i;
A. 369
B. 258
C. 36
D. 25
[单项选择]以下程序的输出结果是( )。
#include<iostream>
using namespace std;
void fun(char**q)
++q;
cout<<*q<<end1;
main( )
static char* s []= "HI","HELLO","TEST";
char**p;
p=s;
fun(p);
system("PAUSE");
return 0;
A. 为空
B. HI C) HELLO D) TEST
[单项选择]下列程序的输出结果是( )。
#include<iostream>
using namespace std;
int main( )
于
chara[]=”Hello,Test”;
Char*p=a;
while(*p)
if(*p)=’a’&&*p(=’z’)
cout<<char(*p+’A’-’a’);
else cout<<*p;
p++;
return 0;
A. hello,test
B. Hello,Test
C. HELLO,TEST
D. hELLO,tEST
[填空题]
下列程序的输出结果是 【15】 。
#include<iostream>
using namespace std;
class base{
public:
int n;
base (int x){n=x;}
virtual void set (int m){n=m;cout<<n<<’’;}
};
class deriveA:public base{
public:
dericeA(int x):base(x){}
void set(int m){n+m;cout<<n<<’’;}
};
Class deriveB:public base{
public:
deriveB(int x):base(x){}
void set(int m){n+m;cout<<n<<’’;}
};
int main( )
{
deriveA d1(1);
deriveB.d2(3);
base*pbase;
pbase=&d1;
pbase->set(1);
pbase=&d2;
pbase->set(2);
return 0;
}
[单项选择]下面程序的运行结果是( )。
#include<iostream>
using namespace std;
class TestClass
static int n;
public:
TestClass ( )
n++;
static int test( )
for(int i=0;i<4;i++)
n++;
return n;
;
int TestClass::n=0;
int main( )
cout<<TestClass::test( )<<" ";
TestClass c1,c2;
cout<<TestClass::test( )<<endl;
return ( );
A. 4,10
B. 4,6
C. 0,6
D. 0,4
[单项选择]有以下程序,输出结果( )。
#include<iostream>
using namespace std;
class Complex
public:
Complex(double r=0,double i=0):re(r),im(i)
double real( )constreturn re;
double imag( )const return im;
Complex operator+(Complex c)constreturn
Complex(re+c.re,im+c.im);
private:
double re,ira;
;
int main( )
Complex a =Complex(1,1)+Complex(5);
cout<<a.real( )<<'+'<<a.imag( )<<'i'<<end1;
return ( );
A. 6+i
B. 2i+5 C) 6+1i D) 1i+5
[单项选择]下面程序的运行结果为( )。
#include<iostream>
using namespace std;
void main( )
int a=1;
switch(a)
case 1:cout<<"1";
case 2:cout<<"2";
break;
default:cout<<"0";
A. 12
B. 120
C. 1
D. 10
[单项选择]以下程序输出结果是( ):
#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;
template<typenameT>
Tfun(Ta,TB) {return (a<=B) a:b;}
int main ( )
{
cout<<fun(3,6)<<’’,’’<<fun(3.14F,6.28F)<<end1;
return 0;
}