资源预览内容
第1页 / 共294页
第2页 / 共294页
第3页 / 共294页
第4页 / 共294页
第5页 / 共294页
第6页 / 共294页
第7页 / 共294页
第8页 / 共294页
第9页 / 共294页
第10页 / 共294页
亲,该文档总共294页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
/* 本答案包括了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();return 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.#includeint 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);printf(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(exponential 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 quarts: );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,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 firstname40,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,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 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 firstname: );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),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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号