《C语言程序设计教程》第三版

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1.5C**************************VeryGood!**************************mian(){printf(**************************);printf(\n);printf(VeryGood!\n);printf(\n);printf(**************************);}1.6abcmian(){inta,b,c,max;printf(a,b,c:\n);scanf(%d,%d,%d,&a,&b,&c);max=a;if(maxb)max=b;if(maxc)max=c;printf(%d,max);}3.6main(){charc1=a,c2=b,c3=c,c4=\101,c5=\116;printf(a%cb%c\tc%c\tabc\n,c1,c2,c3);printf(\t\b%c%c,c4,c5);}aabbccabcAN3.7China4A4EEAChinaGlmreclc2c3c4c5Chinac1c2c3c4c5Glmre#includestdio.hmain(){charc1=C,c2=h,c3=i,c4=n,c5=a;c1+=4;c2+=4;c3+=4;c4+=4;c5+=4;printf(%c%c%c%c%c\n,c1,c2,c3,c4,c5);}Glmre3.91x+a%3*(int)(x+y)%2/4x=2.5,a=7,y=4.72(float)(a+b)/2+(int)x%(int)ya=2,b=3,x=3.5,y=2.512.523.53.10main(){inti,j,m,n;i=8;j=10;m=++i;n=j++;printf(%d,%d,%d,%d,i,j,m,n);}9119103.12aa=12an1a+=a2a-=23a*=2+34a/=a+a5a%=(n%=2)n56a+=a-=a*=a(1)24(2)10(3)60(4)0(5)0(6)044a=3b=4c=5x=1.2y=2.4z=-3.6u=51274n=128765c1=ac2=ba=_3__b=_4__c=_5x=1.200000,y=2.400000,z=-3.600000x+y=_3.600__y+z=-1.20__z+x=-2.40c1=a_or_97(ASCII)c2=b_or_98(ASCII)main(){inta=3,b=4,c=5;longintu=51274,n=128765;floatx=1.2,y=2.4,z=3.6;charc1=a,c2=b;printf(a=%2db=%2dc=%2d\n,a,b,c);printf(x=%f,y=%f,z=%f\n,x,y,z);printf(x+y=%5.2fy+z=%5.2fz+x=%5.2f\n,x+y,y+z,z+x);printf(u=%6ldn=%9ld\n,u,n);printf(%s%s%d%s\n,c1=a,or,c1,(ASCII));printf(%s%s%d%s\n,c2=a,or,c2,(ASCII));}47scanfa=3b=7x=8.5y=71.82c1=Ac2=amain(){intabfloatxycharc1c2scanfa=%d_b=%d&a&bscanf_x=%f_y=%e,&x&yscanf_c1=%c_c2=%c&c1&c2}a=3_b=7_x=8.5_y=71.82_c1=A_c2=a48r=1.5h=3scanfmain(){floatr,h,C1,Sa,Sb,Va,Vb;scanf(%f,%f,&r,&h);C1=2*3.14*r;Sa=3.14*r*r;Sb=4*Sa;Va=4*3.14*r*r*r/3;Vb=Sa*h;printf(C1=%.2f\n,C1);printf(Sa=%.2f\nSb=%.2f\nVa=%.2f\nVb=%.2f\n,Sa,Sb,Va,Vb);}49c=5(F-32)/92main(){floatF,c;scanf(%f,&F);c=5*(F-32)/9;printf(c=%.2f,c);}410getcharc1c21c1c22c1c2ASCIIputcharprintf3charc1c2intc1c2#includestdio.hmain(){charc1,c2;c1=getchar();c2=getchar();putchar(c1);putchar(\n);putchar(c2);putchar(\n);}#includestdio.hmain(){charc1,c2;c1=getchar();c2=getchar();printf(c1=%dc2=%d\n,c1,c2);printf(c1=%cc2=%c\n,c1,c2);}5.15.2C10003&&53&&515.3a=3b=4c=5(1)a+bc&&b==c(2)a||b+c&&b-c(3)!(ab)&&!c||1(4)!(x=a)&&(y=b)&&0(5)!(a+b)+c-1&&b+c/2(1)0(2)1(3)1(4)0(5)15.43abc#includestdio.hmain(){inta,b,c;printf(3);scanf(%d,%d,%d,&a,&b,&c);if(ab)if(bc)printf(max=%d\n,c);elseprintf(max=%d\n,b);elseif(ac)printf(max=%d\n,c);elseprintf(max=%d\n,a);}#includestdio.hmain(){inta,b,c,temp,max;printf(3);scanf(%d,%d,%d,&a,&b,&c);temp=(ab)?a:b;max=(tempc)?temp:c;printf(3%d\n,max);}5.5xy#includestdio.hmain(){intx,y;printf(x);scanf(%d,&x);if(x1){y=x;printf(x=%3d,y=x=%d\n,x,y);}elseif(x10){y=2*x-1;printf(x=%3d,y=2*x-1=%d\n,x,y);}else{y=3*x-11;printf(x=%3d,y=3*x-11=%d\n,x,y);}}5.6ABCDE90A80~90B70~79C60D#includestdio.hmain(){floatscore;chargrade;case2:printf();scanf(%f,&score);while(score100||(score0){printf(\n,);scanf(%f,&score);}switch((int)(score/10)){case10:case9:grade=A;break;case8:grade=B;break;case7:grade=C;break;case6:grade=D;break;case5:case4:case3:case1:case0:grade=E;}printf(%5.1f%c\n,score,grade);}0100(int)(score/10)(score/10)5.75321123#includestdio.hmain(){longintnum;intindiv,ten,hundred,thousand,ten_thousand,place;printf(0~99999);scanf(%ld,&num);if(num9999)place=5;elseif(num999)place=4;elseif(num99)place=3;elseif(num9)place=2;elseplace=1;printf(place=%d\n,place);ten_thousand=num/10000;thousand=num/1000%10;hundred=num/100%10;ten=num%100/10;indiv=num%10;switch(place){case5:printf(%d,%d,%d,%d,%d,ten_thousand,thousand,hundred,ten,indiv);printf(\n);printf(%d%d%d%d%d\n,indiv,ten,hundred,thousand,ten_thousand);break;case4:printf(%d,%d,%d,%d,thousand,hundred,ten,indiv);printf(\n);printf(%d%d%d%d\n,indiv,ten,hundred,thousand);break;case3:printf(%d,%d,%d,hundred,ten,indiv);printf(\n);printf(%d%d%d\n,indiv,ten,hundred);break;case2:printf(%d,%d,ten,indiv);printf(\n);printf(%d%d\n,indiv,ten);break;case1:printf(%d,indiv);printf(\n);printf(%d\n,indiv);break;}}5.8I1010%1020100000I2000001010%107.5%200000I40000020205%400000I600000403%600000I1000000601.5%I10000001001%I(1)if(2)switch151010%57.5%(1)if#includestdio.hmain(){longi;floatbonus,bon1,bon2,bon4,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;printf(i);scanf(%ld,&i);if(i=100000)bonus=i*0.1;elseif(i=200000)bonus=bon1+(i-100000)*0.075;elseif(i=400000)bonus=bon2+(i-200000)*0.05;elseif(i=600000)bonus=bon4+(i-400000)*0.03;elseif(i=1000000)bonus=bon6+(i-600000)*0.015;elsebonus=bon10+(i-1000000)*0.01;printf(%10.2f\n,bonus);}1020101000000.110(num-100000)0.0752040201000000.1100.07520(num-200000)0.0510204060100bon1bon2bon4bon6hon10(2)switchibranchbranch0=i*0.11=bon1+(i-105)*0.0752=bon2+(i-2*105)*0.0534=bon4+(i-4*105)*0.0356=bon6+(i-6*105)*0.01578910=bon10+(i-106)*0.01#includestdio.hmain(){longi;floatbonus,bon1,bon2,bon4,bon6,bon10;intc;bon1=100000*0.1;bon2=bon1+100000*0.075;bon4=bon2+200000*0.05;bon6=bon4+200000*0.03;bon10=bon6+400000*0.015;printf(i);scanf(%ld,&i);c=i/100000;if(c10)c=10;switch(c){case0:bonus=1*0.1;break

1 / 50
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功