阅读下面程序:
include<iostream.h>
void f(int n)
{
int x(5);
static int y(10);
if(n>0)
{
++x;
++y;
cout<<x<<","<<y<<endl;
}
}
void main()
{
int m(1);
f(m),
}
则该程序的输出结果是【 】
下列程序的输出结果是( )。
#include<stdio.h>
VOid p(int *x)
{ printf("%d",++*x);
}
void main()
{ int y=3;
p(&y);
}
A.3
B.4
C.2
D.5
下面程序的运行结果是
#include<iostream.h>
void fun(int * a,int * b)
{
int x= * a;
* a= * b; * b=X;
cout < < * a < < * b < <" ";
}
void main( )
{
int x=1,y=2;
fun(&x,&y) ;
cout < < X < < y < < endl;
}
A.12 12
B.12 21
C.21 12
D.21 21
有如下程序: #include <iostream> void fun (int& x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42}; fun (a[1],a[0]; std::cout<<a[0]<<”,”<<a[1]<<std:: ond1; retum0; }执行后的输出结果是______ 。
A.41,41
B.23,23
C.13,42
D.42,23
阅读下列程序:
include<iostream.h>
void fun(int n)
{
int x(5);
static int y(10);
if(n>0)
{
++x;
++y;
cout<<x<<","<<y<<endl;
}
}
void main()
int m(1);
fun(m);
}
则该程序的输出结果是______。
. .阅读程序写结果试题第四章 选择构造 共20道题1. 于蕾*include void main( ) int x,y,t;x=7;y=9;if(xy) t=x;x=y;y=t;printf(%d,%dn , x,y );运行结果:9,72. 于蕾*include void main( ) int x=1,a=2,b=3; switch(x) case 1: a-; break;case 2: b+; break; case 3: a+;b+; printf(na=%d,b=%dn,a,b);运行结果:a=1,b=33. 于蕾*include void main( ) char ch1 = E; if(ch1 = A) ch1+; else ch1+=32; printf(ch1 = %cn, ch1);运行结果:ch1= F 4. 于蕾*include void main( ) int x,y,t;x=5;y=3;if(xy) t=x;x=y;y=t;printf(%d,%dn , x,y );运行结果:3,55. 王伟*include int main()int a,b,c,m;printf(Enter three integers:);scanf(%d%d%d,&a,&b,&c);if(a=b)m=a;elsem=b;if(cm)m=c;printf(m=%dn,m);return 0;输入:21 22 23运行结果:m=216. 王伟*include int main()char ch1=a,ch2=B,ch3=E;if(ch1ch2)if(ch2ch3)ch3+;else-ch3;printf(ch3=%cn,ch3);return 0;运行结果:ch3=D7. 王伟*include int main()float x,y;scanf(%f,&x);switch(int)x/10)case 0: y=1.0;printf(y=%fn,y);break;case 1: y=2*x+1;printf(y=%fn,y);break;case 2: y=3*x*x+2;printf(y=%fn,y);break;default:printf(No definition.n); return 0;输入:15.3运行结果:y=31.6000008. 王伟*include int main()char ch1=A,ch2=B;switch(ch1)case A:switch(ch2)case B: printf(Good!n);break;case A: printf(Better!n);break;case B: printf(Best!n); break;return 0;运行结果:Good!Best!9 王锋*include void main() float score;score = 100;if (score60) printf(En); else switch( ( int ) score / 10 ) case 10: case 9: printf(An); case 8: printf(Bn); case 7: printf(Cn); break; case 6: printf(Dn); break; default: printf(Errorn); 运行结果:ABC10 王锋*include void main()int i=0,a=2;if(i=0)printf(*);elseprintf($);printf(*);运行结果:*11. 王锋*include void main()int m=10,n=0,p=4,q=20;if (m) if (n) q=15-m;else q=25+m;else if (p) q=q+p;printf(q=%dn,q); 运行结果:q=3512. 王锋*includevoid main()int a=1,b=0;switch(a)case 1: switch (b)case 0: printf(*0*); break; case 1:printf(*1*);break;case 2: printf(*2*);break;运行结果:*0*2*13. 宋昕*includeint main( ) int a=2,b=7,c=5; switch (a0) case 1: switch (b0) case 1: printf(); break ; case 2: printf(!); break ; case 0: switch (c=5) case 1: printf(*) ; break ; default : printf(*) ; break ; default : printf(&); printf(n); return 0;运行结果:*&14. 宋昕*includeint main() int a=0,b=1,c=0,d=20; if(a) d=d-10; else if (!b) if(!c) d=15; else d=25; printf(d=%dn,d); return 0;运行结果:d=2015. 宋昕*includeint main() int a=1; switch(a) case 0: printf(*0*);break; case 1:printf(*1*);break; case 2:printf(*2*);break; return 0;运行结果:*1*16. 宋昕*include int main() int x, y; scanf(%d,&x); y = x12 x + 10 : x - 12; printf(%dn, y); return 0;输入:12运行结果:017. 宋昕*include int main() float x, y; char op; double r; scanf(%c%f%f,&op,&x,&y); switch(op) case +: r = x + y; break; case -: r = x - y; break; case *: r = x * y; break; case /: r = x / y; break; printf(%.1f, r); return 0;输入:3.5运行结果:0.618. 王勇超*include stdio.hvoid main( ) int a=7; if(a9 | a10) a=a/3; else a=a%3; printf(a=%d, a);运行结果:a=219. 王勇超*includevoid main() int a=20; switch(a%3) case 0: printf(0); case 1: printf(1); case 2: printf(2); default: printf(3); printf(4);运行结果:23420. 王勇超*include void main()int a=2,b=5,c=8,t;if ( a b ) t = a; a = b; b = t; if ( b c ) t = b; b = c; c = t; if ( a b ) t = a; a = b; b = t; printf( %d,%dn, a+, -c );运行结果:8,1第五章 循环构造 共20道题1. 于蕾)*include void main() int number , digit; number = 1234; while ( number != 0 ) digit = number%10 ;printf( %d , digit ) ;number = numbe
以下程序运行后的输出结果是【 】。
include<iostream.h>
void fun(int x,int y)
{ x=x+y;y=x-y;x=x-y;
cout<< x << "," <<y << " ,";}
void main( )
{ int x=2,y=3;fun(x,y);
cout<< x << "," << y << endl;}
下列程序的运行结果是【 】。
include <iostream. h>
class Sample {
int x,y;
public:
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, s2(1, 2);
s1. disp0;
s2. disp ();
}
以下程序的执行结果是______。
include<iostream.h>
void main()
{
int x=5 y=2;
cout<<! (y==x/2)<<",";
cout<<(y!=x%3)<<",";
cout<<(x>0 && y<0=<<",";
cout<<(x!=y||x>=y)<<endl;
}
下面程序的结果【 】。
include<iostream.h>
int f(int);
void main() {
int x=1, i;
for (i=0; i<3; i++)
cout<<f(x)<<‘ ’ ;
cout<<end1;
}
int f(int x){
int y=1;
static int z=3
y++;
z++;
return (x+y+z);
}
有如下程序: #include<iostream> void fun(int&x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42}; fun(a[1],a[0]; std::cout<<a[0]<<","<<a[1]<<std::ndl; return 0; } 执行后的输出结果是
A.42,42
B.23,23
C.23,42
D.42,23