C语言程序设计张淑华朱丽莉版课后习题参考答案.docx

上传人:b****3 文档编号:2220419 上传时间:2022-10-28 格式:DOCX 页数:25 大小:21.08KB
下载 相关 举报
C语言程序设计张淑华朱丽莉版课后习题参考答案.docx_第1页
第1页 / 共25页
C语言程序设计张淑华朱丽莉版课后习题参考答案.docx_第2页
第2页 / 共25页
C语言程序设计张淑华朱丽莉版课后习题参考答案.docx_第3页
第3页 / 共25页
C语言程序设计张淑华朱丽莉版课后习题参考答案.docx_第4页
第4页 / 共25页
C语言程序设计张淑华朱丽莉版课后习题参考答案.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

C语言程序设计张淑华朱丽莉版课后习题参考答案.docx

《C语言程序设计张淑华朱丽莉版课后习题参考答案.docx》由会员分享,可在线阅读,更多相关《C语言程序设计张淑华朱丽莉版课后习题参考答案.docx(25页珍藏版)》请在冰豆网上搜索。

C语言程序设计张淑华朱丽莉版课后习题参考答案.docx

C语言程序设计张淑华朱丽莉版课后习题参考答案

C语言程序设计(张淑华、朱丽莉版)课后习题参考答案

C语言程序设计(张淑华、朱丽莉主编)课后习题解答

(仅供参考)

习题一

一、选择题

1.B2.D3.B4.A5.B

6.C7.C

二、填空题

1..obj2.函数3./**/4.#includeinta,b;a,b

三、简答题(略)

习题二

一、选择题

1.B2.B3.A4.D5.A

6.C7.C8.A9.C10.B

11.A12.A13.C14.A15.C

二、填空题

1.变量2.存储数据的单元3.非0、04.

(1)a>=0

(2)0

5.16.17.-308.389.4,7

10.-617777211.9.912.7

三、写出下列程序的运行结果

1.0,0,52.183.6451284.5

5.d4,c

四、编程题

1.#include

#definePI3.1415926

voidmain()

{floatr,s;

printf(“Pleaseinputcircinalradii\n”);

scanf(“%f”,&r);

s=PI*r*r;

printf(“r=%.2f,s=%.2f\n”,r,s);

}

2.#include

voidmain()

{charc1,c2;

printf(“Pleaseinputamajuscule\n”);

scanf(“%c”,&c1);

c2=c1>’A’&&c1<’Z’?

c1+32:

c1;

printf(“%c\n”,c2);

}

3.#include

voidmain()

{inta=0,b;

scanf(“%c”,&b);

b=b&a;

printf(“b=%d\n”,b);

}

习题三

一、选择题

1.C2.C3.A4.C5.D

6.原题第2行应为c=(c-=a-5),(a=b,b+3);答案为B否则输出结果为5,0,5

7.D8.C9.A10.B

二、填空题

1.-50300、a=-50,b=300

a=-50b=300

2.102030、10,20,30、a=10,b=20,c=30

3.15、0、0

三、写出下列程序的运行结果

1.a=789.654321,a=789.65,a=789.65432100,a=789.654321

2.b=15,b=17,b=f3.c=1,x=0,y=0,z=14.21

20,20

5.在TC环境下为216,125在VC环境下为216,180

6.a=A,b=d,c=F7.9,4,12,128.x=4.500000,y=4,x+y=8.500000

四、编程题

1.#include

voidmain()

{printf("**********************************\n");

printf("HAPPYNEWYEAR!

\n");

printf("**********************************\n");

}

2.

(1)#include

voidmain()

{inta=5,b=8,c=10,m,max;

m=a>b?

a:

b;

max=c>m?

c:

m;

printf(“max=%d\n”,max);

}

(2)#include

voidmain()

{inta,b,c,m,max;

scanf("%d,%d,%d",&a,&b,&c);

max=a>b?

a:

(b>c?

b:

c);

printf(“max=%d\n”,max);

}

习题四

一、选择题

1.D2.D3.C4.A5.D

6.A7.C8.C9.D10.B

二、填空题

1.6、5、52.(a%3==0||a%7==0)3.

(1)a>b

(2)a=c;(3)a,b,c

三、写出下列程序的运行结果

1.42.643.a=7,b=44.46465.*#

46

四、编程题

1.另见填空题3

#include

voidmain()

{floata,b,c,t;

scanf("%f,%f,%f",&a,&b,&c);

if(a>b)

{t=a;a=b;b=t;}

if(a>c)

{t=a;a=c;c=t;}

if(b>c)

{t=b;b=c;c=t;}

printf(“%.2f,%.2f,%.2f\n”,a,b,c);

}

2.#include

voidmain()

{inta,b;

scanf("%d,%d",&a,&b);

if(a%b==0)

printf(“%disdivisibleby%d\n”,a,b);

else

printf(“%disnotdivisibleby%d\n”,a,b);

}

3.

(1)#include

voidmain()

{intx,y;

scanf(“%d”,&x);

if(x>-5&&x<0)

y=x;

printf("y=%d\n",y);

elseif(x==0)

y=x-1;

printf("y=%d\n",y);

elseif(x>0&&x<10)

y=x+1;

printf("y=%d\n",y);

else

printf("Dataoutofrange\n");

}

(2)#include

voidmain()

{intx,y;

scanf(“%d”,&x);

switch(x)

{case-1:

case-2:

case-3:

case-4:

y=x;printf("y=%d\n",y);break;

case0:

y=x-1;printf("y=%d\n",y);break;

case1:

case2:

case3:

case4:

case5:

case6:

case7:

case8:

case9:

y=x+1;printf("y=%d\n",y);break;

default:

printf("Dataoutofrange\n");

}

4.#include

voidmain()

{

longnum;

intindiv,ten,hundred,thousand,tenthousand,place;/*分别代表个位、十位、百位、千位、万位和位数*/

printf(“PleaseInputainteger(0~99999):

”);

scanf(“%ld”,&num);

if(num>9999)

place=5;

elseif(num>999)

place=4;

elseif(num>99)

place=3;

elseif(num>9)

place=2;

else

place=1;

printf(“place=%d\n”,place);

printf(“Foreachdigit:

”);

tenthousand=num/10000;

thousand=(int)(num-tenthousand*10000)/1000;

hundred=(int)(num-tenthousand*10000-thousand*1000)/100;

ten=(int)(num-tenthousand*10000-thousand*1000-hundred*100)/10;

indiv=(int)(num-tenthousand*10000-thousand*1000-hundred*100-ten*10);

switch(place)

{

case1:

printf(“%d”,indiv);break;

case2:

printf(“%d,%d”,ten,indiv);break;

case3:

printf(“%d,%d,%d”,hundred,ten,indiv);break;

case4:

printf(“%d,%d,%d,%d”,thousand,hundred,ten,indiv);break;

case5:

printf(“%d,%d,%d,%d,%d”,tenthousand,thousand,hundred,ten,indiv);

}

}

习题五

一、选择题

1.D2.C3.D4.B5.C

6.B7.C8.B9.B10.B

二、填空题

1.

(1)x>=0或!

(x<0)

(2)x

2.

(1)i<10或i<=9

(2)j%3或j%3!

=0

3.

(1)pi

(2)fabs(t)(3)4

三、写出下列程序的运行结果

1.12.y=-13.44.a=2,b=85.*7

6.457.18.s=0

34

23

四、编程题

1.#include

voidmain()

{

inti,j,k;

for(i=1;i<=4;i++)/*输出上面4行*号*/

{for(j=1;j<=5-i;j++)

printf(““);/*输出*号前面的空格*/

for(k=1;k<=2*i-1;k++)

printf(“*”);/*输出*号*/

printf(“\n”);/*输出完一行*号后换行*/

}

}

2.#include"stdio.h"

voidmain()

{intnum,n1,n2,p=1;

scanf("%d",&num);

while(num)

{n1=num/10;

n2=num%10;

p*=n2;

num=n1;

}

printf("num=%d,p=%d\n",num,p);

}

3.#include"stdio.h"

voidmain()

{inti;

floats1,s2,s3,s4,s5,sum,avg;

for(i=1;i<=6;i++)

{printf("Pleaseenterafivesubjectsscore\n");

scanf("%f,%f,%f,%f,%f",&s1,&s2,&s3,&s4,&s5);

sum=0;

sum+=s1+s2+s3+s4+s5;

avg=sum/5;

printf("%dindividuals,theaveragescoreis%.2f\n",i,avg);

}

}

习题六

一、选择题

1.D2.C3.D4.D5.B

6.A7.C8.D9.A

二、填空题

1.地址常量2.非03.3.

(1)j=9

(2)j>=04.

(1)0

(2)6

5.

(1)gets(temp

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1