2022年c程序设计答案-谭浩强.docx
《2022年c程序设计答案-谭浩强.docx》由会员分享,可在线阅读,更多相关《2022年c程序设计答案-谭浩强.docx(37页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精品学习资源c 程序设计 第三版 答案c2,c3,c4,c5;In,c2,c2;作者: 谭浩强新世纪电脑基础训练丛书清华高校出版社2.83.5第一章main571.6int c1,c2;57mainc1=97;c2=98;67.856400,-789.123962int a,b,c,max;printf%c%c,c1,c2;67.856400,-789.123962printfinput three numbe67.86 -789.12,67.85640rs:n;0,-789.123962,67.856400,-78scanf%d,%d,%d,&a,&b,&2.99.123962c;1=2.5
2、6.785640e+001,-7.89e+002max=a;2=3.5A,65,101,41ifmaxbmax=b;1234567,4553207,d687ifmaxb.a:b;case 0:grade=E;scanf%f,&f;max=ctemp.c:temp;c=5.0/9.0*f-32;printfmax=%d,max;printfscore=%d,grade=%c,printfc=%5.2fn,c;score,grade;欢迎下载精品学习资源3.10i ncludestdio.h mainchar c1,c2; scanf%c,%c,&c1,&c2; putcharc1;putchar
3、c2;printfn;printf%c%cn,c1,c2;第四章4.310213140514.4mainint a,b,c; scanf%d,%d,%d,&a,&b,&c;ifabifbcprintfmax=%dn,c;elseprintfmax=%dn,b;else ifacprintfmax=%dn,c;elseprintfmax=%dn,4.5mainint x,y;scanf%d,&x; ifx1y=x;else ifx=0&score9999 place=5; else ifnum999 place=4; else ifnum99 place=3; else ifnum9 place
4、=2; else place=1; printfplace=%dn,place;ten_thousand=num/10000; thousand=num-ten_thousand*10000/1000;hundred=num-ten_thousand*10000-thousand*1000/100; ten=num-ten_thousand*10000-thousand*1000-hundred*100/10;indiv=num-ten_thousand*10 000-thousand*1000-hundred*1 00-ten*10;switchplacecase 5:printf%d,%
5、d,%d,%d,%dn,ten_thousand, thousand,hundred,ten,indiv;printf %d,%d,%d,%d,%dn,indiv,t en,hundred,thousand,ten_tho usand;break;欢迎下载精品学习资源a;欢迎下载精品学习资源case 4:printf%d,% d,%d,%dn,thousand,hundred, ten,indiv;printf %d,%d,%d,%dn,indiv,ten, hundred,thousand;break; case 3:printf%d,%d,%dn,hundred,ten,indiv;pri
6、ntf %d,%d,%dn,indiv,ten,hun dred;break; case 2:printf%d,%dn,ten,indiv;printf%d,%dn,indiv,ten;break;case 1:printf%dn,indiv;printf%dn,indiv;4.8mainlong i;float bonus,bon1,bon2,bon 4,bon6,bon10;bon1=100000*0.1;bon2=bon1+100000*0.075; bon4=bon2+200000*0.05; bon6=bon4+200000*0.03; bon10=bon6+400000*0.015
7、;scanf%ld,&i; ifi=1e5bonus=i*0.1; else ifi=2e5bonus=bon1+i-100000*0.075;else ifi=4e5bonus=bon2+i-200000*0.05;else ifi=6e5bonus=bon4+i-400000*0.03;else ifi10branch=10; switchbranchcase 0:bonus=i*0.1;break;case 1:bonus=bon1+i-100 000*0.075;break;case 2:case 3:bonus=bon2+i-200 000*0.05;break;case 4:cas
8、e 5:bonus=bon4+i-400 000*0.03;break;case 6:case 7case 8:case 9:bonus=bon6+i-600 000*0.015;break;case 10:bonus=bon10+i-1 000000*0.01;printfbonus=%10.2f,bon us;4.9mainint t,a,b,c,d; scanf%d,%d,%d,%d,&a,&b,&c,&d;ifabt=a;a=b;b=t;ifact=a;a=c;c=t;ifadt=a;a=d;d=t;ifbct=b;b=c;c=t;ifbdt=b;b=d;d=t;ifcdt=c;c=d
9、;d=t;printf%d%d%d%dn,a,b,c,d;4.10mainint h=10;float x,y,x0=2,y0=2,d1,d2, d3,d4;scanf%f,%f,&x,&y;d1=x-x0*x-x0+y-y0* y-y0;d2=x-x0*x-x0+y+y0* y+y0;d3=x+x0*x+x0+y-y0* y-y0;d4=x+x0*x+x0+y+y0* y+y0;ifd11&d21&d31&d41h=0;printfh=%d,h;第五章循环把握5.1mainint a,b,num1,num2,temp; scanf%d,%d,&num1,&num2;ifnum1=a&c=A&
10、c=0&c= 9digit+;else other+;printfletters=%dnspace=%dndigit=%dnother=%dn,float k;float s1=0,s2=0,s3=0; fork=1;k=N1;k+s1+=k; fork=1;k=N2;k+s2+=k*k; fork=1;k=N3;k+s3+=1/k; printfs=%8.2fn,s1+s2+s3;5.6mainint i,j,k,n; forn=100;n1pri欢迎下载精品学习资源mainint a,n,count=1,sn=0,tn=0; scanf%d,%d,&a,&n; whilecount=ntn
11、+=a;sn+=tn; a*=10;+count;printfa+aa+aaa+.=%dn ,sn;5.4mainfloat n,s=0,t=1; forn=1;n=20;n+t*=n;s+=t;=%dn,n;5.7#define M 1000 mainint k0,k1,k2,k3,k4,k5,k6,k 7,k8,k9;int i,j,n,s; forj=2;j=M;j+n=0;s=j; fori=1;i2priifn3priifn4priifn5priifn6priifn7priifn8priifn9pri欢迎下载精品学习资源sn=sn+2*hn;-6;hn=hn/2;f1=6*x0-8*
12、x0+3;x=x0-f/f1;mainprintfsn=%fn,sn;static int k10;printfhn=%fn,hn;whilefabsx-x0=1e-5;int i,j,n,s;printfx=%6.2fn,x;forj=2;j=1000;j+n=-1;5.10s=j;main5.13fori=1;i0dokn=i;x1=x2+1*2;scanf%f,%f,&x1,&xx2=x1;2;day-;fx1=x1*2*x1-4*x1+ifs=03-6;printfj=%dn,printfx1=%dn,x1;fx2=x2*2*x2-4*x2+j;3-6;fori=0;i0;printf
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022 程序设计 答案 谭浩强
限制150内