c语言答案-贾宗璞 许合利,C语言习题答案贾宗璞许合利较全-.doc

96f4938f6e70ea43fb5afefe86d9be82.gifC语言习题答案贾宗璞许合利较全-.doc

参考答案习题一1、 选择题CBACD2、 填空题1) main2) main3) 有穷性、确定性、有效性、0个到多个输入、1个到多个输出4) 顺序、选择、循环5) 自顶向下、逐步细化、模块化设计、限制goto习题二1、 选择题ACCDA DDAAC BBACC2、 填空题1) 字母、数字、下划线2) 03) 4 84) a b * c / a c 5) -606) -167) 98) 6 4 29) 010) 10 611) 12 412) 3.50000013) 014) 1615) 6.63、编程题(1)编写一个程序求各种类型数据的存储长度。include stdio.hvoid mainprintfintd byten,sizeofint;printfshort intd byten,sizeofshort int;printflong intd byten,sizeoflong int;printffloatd byten,sizeoffloat;printfdoubled byten,sizeofdouble;printflong doubled byten,sizeoflong double;printfchard byten,sizeofchar;include stdio.hdefine RAT 1.60934void mainfloat k;printf the km;scanff,printfmilefn,k/RAT;习题三1、 选择题DACDD DCDCC2、 解析题1)include stdio.hvoid main int x170; float a513.789215; printfx3d,x6d,x6o,x6x,x6un,x,x,x,x,x; printfx-3d,x-6d,x6d,x6dn,x,x,x,x; printfa8.6f,a8.2f,a14.8f,a14.8lfn,a,a,a,a;结果x170,x 170,x 252,x aa,x 170 x170,x170 ,x 170,x6da513.789185,a 513.79,a 513.78918457,a 513.789184572)include stdio.hmain int a,b; float x,y; char c1,c2; scanfad bd, scanfxf yf, scanfc1c c2c, printfad,bd,xf,yf,c1c,c2c,a,b,x,y,c1,c2;正确输入格式A3 b7x8.5 y71.82c1A c2a3、 编程题1)include stdio.hvoid main int x,y; scanfdd, printf商数d,余数d,x/y,xy; 2)include stdio.hvoid main double x,y,z,avg; scanflflflf, avgxyz/3; printf.1f,avg;习题四1、 选择题CCAAD CCABD2、 填空题1 a0b0a0c0b0c0 abac fabsa5 a0 ab02 x0 1 x0 x53 3 2 24 chA chZ chch-325 x2x10 x-1x2 y -16 abc bca acb ab ca ab bc ac7 x0 cx/10 x -23、 编程题1include stdio.hmain int x; printfplease a number; scanfd, ifx20 printfx is a even number; else printfx is a odd number;2include stdio.hmain int x,y; printfplease a number; scanfd, ifx-5 x0 yx; printfd,y; else ifx0 yx-1; printfd,y; else ifx0 x10 yx1; printfd,y; else printfthe number is error;3include stdio.hmain int a,m; printfplease a number; scanfd, switcha/10 case 0 case 1 case 2m1;break; case 3m2;break; case 4m3;break; case 5m4;break; defaultm5;break; printfd,m;4include stdio.hmain float price,tax; printfplease the price of product; scanff, ifprice10000 taxprice*0.05; else ifprice5000 taxprice*0.03; else ifprice1000 taxprice*0.02; else tax0; printff,tax;5include stdio.hmain float score; printfplease the score of student; scanff, ifscore85 printfVERY GOOD; else ifscore60 printfGOOD; else printfBAD;6include stdio.hmain int x,y,z;printf two number;scanfdd,ifx10 x99 y10 y99printf data errorn;elsezx/10*1000y/10*100x10*10y10; printfdn,z;习题五1、 选择题DCADA DDBDB CADAC2、 填空题1 fahr celsius5.0/9*fahr-32; fahrstep;2 i5 j4 k63 3*i-24 y z*x 5 8 5 26 j ij0 ji 7 sumk sumk j-28 s0 p1 ji3、 改错题1)include stdio.hmain int n,k; float score,sum,ave; /found/ forn1;n10;n sum0.0; fork1;k4;k scanff, sumscore; /found/ avesum/4; printfNO.dfn,n,ave; 2)include stdio.hmain int i,j,k,m; fori1; i9; i /*found / forj0; j9 ; j fork0; k9; k /* found */ m100*i10*jk; ifmi*i*ij*j*jk*k*k printfd ,m; 3)include stdio.hmain double r,eps,temp; int m1; printfnPlease enter a precision ; scanflf, r0.0; /*found*/ temp1; /found/ whiletemp eps rtemp; temptemp*m/2*m1; m; /found/ printfnepslf,Pilfnn,eps,r*2;4)include stdio.hmain int m0,mix0,n; /found/ scanfd, whilen2 mix10 /*found*/ ifn110 n190 mmn; mix; n; printfdn,m;5)include stdio.hmain unsigned m; int n0,max0,t; scanfd, do /*found/ tm10; /*found/ ift0 n; ifmaxt maxt; /*found/ mm/10; whilem; printfnThe result maxd zdn,max,n;4、 编程题1)include stdio.hmainint s;float n,t,sum;t1; sum0; n1; s1.0;whilen100 sumsumt; nn1; s-s; ts/n;printfsum10.6fn,sum;2)include stdio.hmain int i; long int n1; fori1;i10;i nn*i; printfi502d-10ldn2d-10ld,i,n; 3)include stdio.hmain int n,i,j; scanfd, fori1;in;i forj1;jni-1;j ifjn-i printf ; else printf*; printfn; 4)include stdio.hmain int m,s,i; form2;m1000;m s0; fori1;im;i ifmi0 ssi; ifsm printfd its factors are ,m; fori1;im;i ifmi0 printfdi; printfn; 5)include stdio.hmain int h10,h7,h5; forh100;h108;h10 forh70;h78;h7forh50;h58;h5ifh10h7h58 h10*10h7*7h5*553printfh10dth7dth5dn,h10,h7,h5;6)include stdio.hmain int day,x1,x2; day9; x21; whileday0 x1x21*2; 第一天的桃子数是第2天桃子数加1后的2倍 x2x1; day; printfthe total is dn,x1; 7)include stdio.hincludemath.hmain float x,x0,f,f1; x1.5; 可改为scanff,do x0x; f2*x0*x0*x0-4*x0*x03*x0-6; f16*x0*x0-8*x03; f的导数,即它的切线 xx0-f/f1; 切线与x轴的交点 whilefabsx-x01e-5; printfThe root is 8.7fn,x; 8)include stdio.hmain int p,r,n,m,temp; printf two integer n,m; scanfd,d, ifnm tempn; nm; mtemp; 确保mn pn*m; whilem0 rnm; nm; mr; printfgreatest common divisor isdn,n; 最大公约数 printflease common multiple isdn,p/n; 最小公倍数45

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值