执行下列程序的结果是main(){float x=1,y;y=++x *++x;cout<<y<<end1;}
A.9
B.6
C.1
D.程序有错误
第1题:
下列程序的输出结果是 ______。 #include<iostream.h> void main() { int x=6,y=8; if(x1++<6) cout<<++y<<end1; if(x>6) cout<<--y<<end1; else cout<<y++<<end1; }
A.8
B.9
C.7
D.编译不成功
第2题:
下列程序段的输出结果是 #include<iostream.h> void fun(int * X,int * y) { cout < < * X < < * y; * X=3; * y=4; } void main( ) { int x=1,y=2; fun(&y,&x); cout < < X < < y < < end1; }
A.2143
B.1212
C.1234
D.2112
第3题:
下列程序的执行结果是______。 #include<iostream.h> #include<stdlib.h> class TestClass { public: int x,y; TestClass () {x=y=0;} TestClass (int a,int b){x=a;y=b;} void disp() { cout<<"x="<<x<<",y="<<y<<end1; } void main() TestClass s1(2,3); s1.disp(); }
A.x=2,y=2
B.x=2,y=3
C.x=3,y=2
D.x=3,y=3
第4题:
如下程序的输出结果是main(){float x=2.0, y;if(x<0.0)y=0.0;else if(x<10.0)y= 1.0/x;else y= 1.0cout<<y<<end1}
A.0
B.0.25
C.0.5
D.1
第5题:
下列程序的执行结果是( )。 #include<iostream.h> class Sample { int x,y; public: Sample() {x=y=0;} Sample(int a,int b) {x=a;y=b;} ~Sample() { if(x==y) cout<<"x=y"<<end1; else cout<<"x!=y"<<end1; } void disp() { cout<<"x="<<x<<",y="<<y<<end1; } }; void main() { Sample s1(2,3); s1.disp(); }
A.x=2,y=2
B.x=3,y:3
C.x=2,y=3
D.x=3,y=2
第6题:
下列程序的执行结果是( )。 #include<iostream.h> #include<stdlib.h> Class TestClass { public: int x,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<"x="<<x<<",y="<<y<<end1; } }; void main() { TestClass s1(2,3); s1.disp(); }
A.x=2,y=2
B.x=3,y=3
C.x=2,y=3
D.x=3,y=2
第7题:
下列程序执行后,屏幕的输出是( )。 #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 x=3,y=2
B.x=2,y=3 x=3,y=2
C.x=2,y=3 x=2,y=3
D. x=3,y=2 x=2,y=3
第8题:
以下程序的执行结果是【 】。
include<iostream.h>
include<stdlib.h>
class Sample
{
public:
int x,y;
Sample(){x=y=0;}
Sample(int a,int b) {x=a;y=b; }
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main() {
Sample s1(2,3);
s1.disp();
}
第9题:
分析以下程序的执行结果【 】。
include<iostream.h>
class Sample
{
int x, y;
public:
Sample() {x=y=0; }
Sample(int a, int b) { x=a; y=b;}
~Sample()
{
if(x==y)
cout<<"x=y"<<end1;
else
cout<<"x!=y" <<end1;
}
void disp()
{
cout<<"x="<<x<<",y="<<y<<end1;
}
};
void main()
{
Sample s 1 (2,3);
s1.disp();
}