Cprimerplus(第六版)习题答案.docx

上传人:marr****208 文档编号:132275495 上传时间:2020-05-14 格式:DOCX 页数:294 大小:161.95KB
返回 下载 相关 举报
Cprimerplus(第六版)习题答案.docx_第1页
第1页 / 共294页
Cprimerplus(第六版)习题答案.docx_第2页
第2页 / 共294页
Cprimerplus(第六版)习题答案.docx_第3页
第3页 / 共294页
Cprimerplus(第六版)习题答案.docx_第4页
第4页 / 共294页
Cprimerplus(第六版)习题答案.docx_第5页
第5页 / 共294页
点击查看更多>>
资源描述

《Cprimerplus(第六版)习题答案.docx》由会员分享,可在线阅读,更多相关《Cprimerplus(第六版)习题答案.docx(294页珍藏版)》请在金锄头文库上搜索。

1、/* 本答案包括了C primer plus 第六版中文版 2 17 章几乎所有习题 */* 所有题目纯手打 如发现错误 或想互相交流学习 可加QQ 420536405 */C Primer Plus第六版中文版习题答案第二章答案3.#includeint main(void)int days,years=21;days=years*365;printf(我的年龄是%d岁,%d天n,years,days); return 0;4. #includevoid jolly(void);void deny(void);int main(void)jolly();jolly();deny();retu

2、rn 0;void jolly(void)printf(For hes a jolly good fellow!n);void deny(void)printf(Which nobody can deny!n);5.#includevoid br(void);void ic(void);int main(void)br();printf(,); ic();printf(n);ic();printf(n);br();printf(n);return 0;void br(void)printf(Brazil,Russia);void ic(void)printf(India,China);7.#i

3、ncludeint main(void)int toes=10;int toes_2,toes2;toes_2=2*toes;toes2=toes*toes;printf(toes是%d,toes的两倍是%d,toes的平方是%dn,toes,toes_2,toes2); return 0;8.#includevoid one_three(void);void two(void);int main(void)printf(starting nown); one_three();void one_three(void)printf(onen);two();printf(threen);print

4、f(done!n);void two(void)printf(twon);第三章(2.4.5.6.7.8)2.#includeint main(void)char ch;printf(please input a number:);scanf(%d,&ch);printf(%cn,ch);return 0;4./C99之前版本 不适用p计数法#includeint main(void)float a;printf(Enter a floating-point value: );scanf(%f,&a);printf(fixed-point notation: %fn,a);printf(exp

5、onential notation: %en,a); return 0;5. #includeint main(void)int age;double seconds; printf(please input your age: );scanf(%d,&age);seconds=age*3.156e7;printf(the corresponding seconds are: %en,seconds); return 0;6. #includeint main(void)double quarts,n;double m=3.0e-23;printf(input the number of qu

6、arts: );scanf(%lf,&quarts); n=quarts*950/m;printf(the numble of H2O molecules is: %en,n);return 0;7.#includeint main(void)float inches,cms;printf(input your height(inch): );scanf(%f,&inches); cms=inches*2.54;printf(your height(cm): %fn,cms);return 0;8.#includeint main(void)float pint,ounce,soupspoon

7、,teaspoon,cup;printf(input the number of cups: );scanf(%f,&cup);pint=cup/2;ounce=cup*8;soupspoon=ounce*2; teaspoon=soupspoon*3;printf(they are equivalent of:n%f pintn%f ouncen%f soupspoonsn%f teaspoonsn,pint,ounce,soupspoon,teaspoon);return 0;第四章(1.2.4.5.6.7.8)1.#includeint main(void)char firstname4

8、0,lastname40;printf(Input your firstname: );scanf(%s,firstname);printf(Input your lastname: ); scanf(%s,lastname); printf(Your name is %s,%sn,firstname,lastname);return 0;2.#include#includeint main(void)char name40; int width;printf(Input your name: );scanf(%s,name);width=strlen(name)+3;printf(%*sn,

9、width,name); /输入的名和姓中间不能分隔return 0;4. /身高输入单位为cm,输出为m#includeint main(void)float height;char name40;printf(Input your height(cm) and name: );scanf(%f%s,&height,name);height=height/100;printf(%s, you are %.3fm talln,name,height);return 0;5.#includeint main(void)float speed,size,time;printf(Input the

10、download speed(Mb/s) and the file size(MB):n);scanf(%f%f,&speed,&size);time=size/speed*8.0;printf(At %.2f megabits per second, a file of %.2f megabytesn,speed,size);printf(downloads in %.2f seconds.n,time);return 0;6.#include#includeint main(void)char firstname40,lastname40;printf(Input your firstna

11、me: );scanf(%s,firstname);printf(Input your lastname: );scanf(%s,lastname);printf(%s %sn,firstname,lastname);printf(%*d %*dn,strlen(firstname),strlen(firstname),strlen(lastname),strlen(lastname); printf(%s %sn,firstname,lastname); printf(%*d %*dn,-strlen(firstname),strlen(firstname),-strlen(lastname

12、),strlen(lastname);return 0;7.#include#includeint main(void)double a=1.0/3.0;float b=1.0/3.0;printf(%.6f %.6fn,a,b); /左侧double型 右侧float型printf(%.12f, %.12fn,a,b);printf(%.16f, %.16fn,a,b);printf(DBL_DIG: %dn,DBL_DIG);printf(FLT_DIG: %dn,FLT_DIG);return 0;8.#include#define GALLON 3.758 /1 gallon=3.785 liters#define MILE 1.609 /1 mile=1.609 kilometersint main(void) float gallon,mile;printf(Input miles and gallons: );scanf(%f%f,&mile,&gallon);printf(Miles per gallon: %.1

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号