1、 1第一章 答案一、选择填空1 2 3 4 5 6 7 8 9 10C B D A D A D D A C二、判断下列描述的正确性,对者划,错者划。1 2 3 4 5 6 7 8 9 10 11 12 三、析下列程序的输出结果1 BeiJjing ShangHai TianJing2 Input a,b:8 5A=8,b=5A-b=33 D=5,c=m四、编译下列程序,改正所出现的各种错误信息,并分析输出结果:1#includevoid main()coutvoid main( )int x;cinx;int p=x*x;coutvoid main ( )int i,j;i=5;j=3;int
2、 k=i+j;coutvoid main()float c,f;coutf;c=(f-32)*5/9;cout3const float r=1.60934; void main()float m,I;coutm;I=r*m;coutvoid main()int n,m;coutn;m=n|15;coutvoid main()int I=1,s=0;while(Ivoid main()int I=13,m;while (Ivoid main()int r,I,j;coutI;5coutj;if (Ivoid main()int x,y,s;coutIj;s=x;while(1)if(s%y= =
3、0)break;s+=x;coutvoid main()int I,m,n,k;float s=0;m=1;n=2;for(I=1;Ivoid main()int I,n=1;long int s=0;for(I=1;I#include void main()int I,n=0;for(I=1;Ivoid main()double x,y;coutx;if(x=10) y=x-5;else y=x+5;cout#include void main()double a,b,c,d,x1,x2;coutabc;d=b*b-4*a*c;if(a=0)cout0)7 x1=(-b+sqrt(d)/2*
4、a;x2=(-b-sqrt(d)/2*a;coutvoid main()for(int i=1;i# include #includechar *func(int,int);void main()cout#include double func(int,int,int,int);double func(double,double,double,double);void main()coutint func(int n=2);void main()coutfunc(1)”,”;coutfunc()”,”;coutfunc(3)endl;int func(int n)int s=0;for(int
5、 I=1;I=10;I+)s=n*(1+s);return s;第五章 答案一、选择填空1 2 3 4 5 6 7 8 9 1010A C D C D A C A D A二、判断下列描述的正确性,对者划,错者划。1 2 3 4 5 6 7 8 9 10 三、分析下列程序的输出结果。4 Default constructor called.Constructor called.A=0,b=0A=4,b=85 A=7,b=96 1047 1035,789,5048 11,2,3,4,5,6,7,8111,12,13,14,15,16,17,18,1919,18,17,16,15,14,13,12,
6、11第六章 答案一、选择填空1 2 3 4 5 6 7 8 9 10 11 12C A B C C D B C A D C B二、判断下列描述的正确性,对者划,错者划。1 2 3 4 5 6 7 8 9 10 11 12 三、分析下列程序的输出结果。1 Starting 1 . . . Default constructor called.Default constructor called.Default constructor called.Ending1. . .Starting2 . . .Constructor: a=1,b=2Constructor: a=3,b=4Constructor: a=5,b=6Ending2 . . .Destructor called. A=5,b=6Destructor called. A=3,b=4Destructor called. A=1,b=2Destructor called. A=5,b=6