下列程序的运行结果为【 】。
include<iostream.h>
void main(void)
{int a=2,b=-1,c=2;
if(a<b)
if(b<0)c=0;
else c=c+1;
cout<<c<<endl;
}
第1题:
下面程序的结果为______。
include<iostream.h>
void main()
{
int 3=1,b=2;
bool c=1;
if(a>b)||c)cout<<“true”<<endl;
else
cout<<“false”<<endl;
}
第2题:
下列程序的输出结果是______。
include <iostream.h>
include <cstring.h>
using namespace std;
void fun(const char*s,char &C) {c=s[strlen (s)/2];}
int main {)
{
char str [] ="ABCDE";
char ch=str[1];
fun(str,sh);
cout<<Ch;
return 0;
}
第3题:
下列程序的运行结果是______。
include<iostream.h>
class Base
{
public:
void f(int x){cout<<“Base:”<<x<<endl;}
);
class Derived:public Base
{
public:
void f(char*str){cout<<“Derived:”<<str<<endl;}
};
void main(void)
{
Base*pd=ne
第4题:
下面程序运行时输出结果为【 】。
include<iostream.h>
include<malloc.h>
class Rect
{
public:
Rect(int1,int w)(length=1;width=w;)
void Print(){cout<<"Area:"<<length *width<<endl;)
void *operator new(size-t size){return malloc(size);}
void operator delete(void *p){free(p)
private:
int length,width;
};
void main()
{
Rect*p;
p=new Rect(5,4);
p->Print();
delete p;
}
第5题:
下列程序的运行结果为【 】。
include<iostream.h>
void main(void)
{int i=10;
switch(i)
{ case 9:i=i+1;
case 10:i=i+1;
case 11:i=i+1;
default:i=i+1;
}
cout<<i<<endl;
}
第6题:
下列程序的执行结果是【 】。
include <iostream. h>
int a;
int sum_a(void)
{
a=a+5;
return a;
}
void main(void)
{
a = a+sum_a();
cout<<a<<endl;
}
第7题:
下面程序运行时输出结果为______。
include<iostream.h>
include
class Rect
{
public:
Rect(int l, int w){length=l; width=w;)
void Print(){cout<<"Area:"<<length*width<<end1;}
void operator delete(void*p){free(p);}
private:
int length, width;
};
void main()
{
Rect *p;
p=new Rect(5, 4);
p->Print();
delete p;
}
第8题:
下列程序的运行结果为( )。 #include<iostream.h> template<class TT> class FF {TT a1,a2,a3; public: FF(TT b1,TT b2,TT b3){a1=b1;a2=b2;a3=b3;} TT Sum(){return a1+a2+a3;}}; void main() {FF<int>x(int(1.1),2,3),y(int(4.2),5,6); cout<<x.Sum(
A.6.1 15.2
B.6 15
C.6 15.2
D.6.1 15
第9题:
下列程序的运行结果是( )。 #include< iostream.h> void fun (int *a,int*b) {int*k k=a;a=b;b=k} void main() {int a=2004, b=9,*x=&a,*y=&b; fun(x, y) ; cout<<a<<" "<<b<<endl:}
A.20049
B.92004
C.0
D.编译时出错