C语言1-5章课后习题答案.ppt

  1. 1、本文档共22页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C语言1-5章课后习题答案

电信学院 蒋玉莲 1.5 #include stdio.h void main( ) { printf(“******************************\n”); printf(“\n”); printf(“□□□□□□□Very good!\n”); printf(“\n”); printf(“******************************\n”); } 1.6 方法一: #include stdio.h void main() { int a,b,c,max; scanf(“%d,%d,%d”,a,b,c); max=a; if(maxb) max=b; if(maxc) max=c; printf(“The max is %d”, max); } 方法二: #include stdio.h void main() { int max(int x, int y); int a,b,c,d,e,f; scanf(%d,%d,%d,a,b,c); d=max(a,b); e=max(a,c); f=max(d,e); printf(The max is %d\n, f); } int max(int x, int y) { int z; if (xy) z=x; else z=y; return z; } 4.4 #includestdio.h void main() { int a, b, c; long int u, n; float x, y, z; char c1, c2; a=3; b=4; c=5; x=1.2; y=2.4; z= -3.6; u=51274; n=128765; c1=‘a’; c2=‘b’; printf(“a=%2d□□b=%2d □□ c=%2d \n”, a, b, c ); printf(“x=%8.6f, y=%8.6f, z=%9.6f\n”, x, y, z); printf(“x+y=%5.2f □□ y+z=%5.2f □□ z+x=%5.2f\n”,x+y,y+z,z+x); printf(“u=%6ld □□n=%9ld\n”,u,n); printf(“c1=‘%c’ □or □%d(ASCII)\n”,c1,c1); printf(“c2=‘%c’ □or □%d(ASCII)\n”,c2,c2); } * 第一章习题 习题3.7 #includestdio.h void main( ) { char c1=‘c’,c2=‘h’,c3=‘i’,c4=‘n’,c5=‘a’; c1+=4; c2+=4; c3+=4; c4+=4; c5+=4; printf(“the cipher is: %c %c %c %c %c\n”,c1,c2,c3,c4,c5); } 第三章习题 习题3.9 x+a%3*(int)(x+y)%2/4 设x=2.5,a=7,y=4.7 答案为2.5 (float)(a+b)/2+(int)x%(int)y 设 a=2,b=3,x=3.5,y=2.5 答案为3.5 习题3.12 (1) a=24 (2) a=10 (3) a=60 (4) a=0 (5) a=0 (6) a=0 第四章习题 习题4.8:圆半径r=1.5,圆柱高h=3,求圆周长、圆面积、圆球表面积、圆球体积、圆柱体积。输出的结果取小数点后2位数字。 #includestdio.h void main() { float pi, h, r, l, s, sq, vq, vz; pi=3.1415926; printf(“input r, h:\n”); scanf(“%f,%f”, r, h); l=2*pi*r; s

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档