《谭浩强C语言程序设计习题答案.pdf》由会员分享,可在线阅读,更多相关《谭浩强C语言程序设计习题答案.pdf(103页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、谭浩强C语言程序设计习题参考答案第一章1.6main()int a,b,c,max;printf(input three numbers:n,,);scanf(%d,%d,%d,&a,&b,&c);max=a;if(maxb)max=b;if(maxc)max=c;printf(max=%d”,max);)第一早2.3(10)10=(12)8=(a)16(2)(32)10=(40)8=(20)16(3)(75)10=(113)8=(4b)16(4)(-617)10=(176627)8=(fd97)16(5)(-lll)10=(177621)8=(ff91)16(6)(2483)10=(4663
2、)8=(963)16(7)(-28654)10=(110022)8=(9012)16(8)(21003)10=(51013)8=(520b)162.6aab b (8)cc(8)ab c(7)AN2.7m ain ()char cl=C,c2=,h,c3=1,c4-n,c5=a;cl+=4,c2+=4,c3+=4,c4+=4,c5+=4;p r in tf(,/%c%c%c%c%c n,,cl,c2,c3,c4,c5);)2.8m ain ()in t cl,c2;cl=97;c2=98;p r in tf C%c%c,)cl,c2);)2.9(1)=2.5(2)=3.52.109,11,9,
3、102.12(1)24(2)10(3)60(4)0(5)0(6)0第三章3.4m ain ()in t a,b,c;l o n g in t u,n;fl o at x,y,z;char cl,c2;a=3;b=4;c=5;x=l.2;y=2.4;z=-3.6;u=51274;n=128765;cl=a;c2=b;p r in tf(n);p r in tf(,a=%2d b=%2d c=%2d n”,a,b,c);p r in tf(x=%8.6f,y=%8.6f,z=%9.6f n”,x,y,z);p r in tf(x+y=%5.2f y+z=%5.2f z+x=%5.2f n”,x+y
4、,y+z,z+x);p r in tf(u=%61d n=%91d n”,u,n);p r in tf(cl=%c o r%d(AS CH)n”,cl,cl);p r in tf(c2=c o r%d(AS CH)n”,c2,c2);3.5575 767.856400,-789.12396267.856400,-789.12396267.86-789.12,67.856400,-789.123962,67.856400,-789.1239626.785640e+001,-7.89e+002A,65,101,411234567,4553207,d68765535,177777,COMPU T E
5、R,COM3.6a=3 b=7/x=8.5 y=71.82/cl=A c2=a/3.710 20Aal.5-3.75+1.4,67.8/(空3)10(空3)20Aal.5(空1)-3.75(空1)(随意输入一个数),67.8回车3.8m ain ()fl o at p i,h,r,1,s,sq,sv,sz;pi=3.1415926;printf(input r,hn);scanf(%f,%f,&r,&h);=2*pi*r;s=r*r*pi;sq=4*pi*r*r;sv=4.0/3.0*pi*r*r*r;sz=pi*r*r*h;printf(1=%6.2fn,1);printf(,s=%6.2f
6、n,s);printf(,sq=%6.2fn,sq);printf(vq=%6.2fn,sv);printf(vz=%6.2fn,sz);)3.9main()float c,f;scanf&f);c=(5.0/9.0)*(f-32);printf(,c=%5.2fn,c);3.10#in cl ude,zstdio.hm ain ()char cl,c2;scan f(%c,%c”,&cl,&c2);p utchar(cl);p utchar(c2);p r in tf(n);p r in tf(,/%c%c n,/,cl,c2);)第四章4.3(1)0(2)1(3)1(4)0(5)14.4m
7、 ain ()in t a,b,c;scan f(%d,%d,%d,&a,&b,&c);if(ab)if(b c)p r in tf(m ax=%d n ,c);e l sep r in tf(in ax=%d n”,b);e l se if(ab)?a:b;max=(ctemp)?c:temp;printf(max=%d”,max);)4.5main()int x,y;scanf(%d,&x);if(xl)y=x;else if(x y);4.6m ain ()in t sco r e,te m p,l o gic;char gr ade;l o gical;whil e (l o gic)
8、scan f(级d”,&sco r e);if(sco r e=0&sco r e 9999)place=5;else if(num999)place=4;else if(num99)place=3;else if(num9)place=2;else place=l;printf(place=%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-t
9、housand*1000-hundred*100)/10;indiv=num-ten_thousand*10000-thousand*1000-hundred*100-ten*10;switch(place)case5:printf(%d,%d,%d,%d,%dn,ten_thousand,thousand,hundred,ten,indiv);printf(,%d,%d,%d,%d,%dn”,indiv,ten,hundred,thousand,ten thousand);break;case4:printf(%d,%d,%d,%dn”,thousand,hundred,ten,indiv)
10、;printf(%d,%d,%d,%dn”,indiv,ten,hundred,thousand);break;case 3:printf(%d,%d,%dn”,hundred,ten,indiv);printf%d,%dn”,indiv,ten,hundred);break;case 2:printf(,%d,%dn,ten,indiv);printf(%d,%dn”,indiv,ten);break;case 1:printf(,%dn,,indiv);printf(dn,indiv);4.8main()long i;float bonus,bonl,bon2,bon4,bon6,bonl
11、O;bonl=100000*0.1;bon2=bonl+100000*0.075;bon4=bon2+200000*0.05;bon6=bon4+200000*0.03;bonl0=bon6+400000*0.015;scanf&i);if(i=le5)bonus=i*0.1;else if(K=2e5)bonus=bonl+(i-100000)*0.075;else if(i=4e5)bonus=bon2+(i-200000)*0.05;else if(i=6e5)bonus=bon4+(i-400000)*0.03;else if(i10)branch=10;switch(branch)c
12、ase 0:bonus=i*0.1;break;case 1:bonus=bonl+(i-100000)*0.075;break;case 2:case 3:bonus=bon2+(i-200000)*0.05;break;case 4:case 5:bonus=bon4+(i-400000)*0.03;break;case 6:case 7case 8:case 9:bonus=bon6+(i-600000)*0.015;break;case 10:bonus=bonl0+(i-1000000)*0.01;printf(bonus=%10.2f”,bonus);)4.9main()int t
13、,a,b,c,d;scanf(d,%d,%d,%d,&a,&b,&c,&d);if(ab)t=a;a=b;b=t;if(ac)t=a;a=c;c=t;if(ad)t=a;a=d;d=t;if(bc)t=b;b=c;c=t;if(bd)t=b;b=d;d=t;if(cd)t=c;c=d;d=t;printf(%d%d%d%dn”,a,b,c,d);)4.10main()int h=10;float x,y,x0=2,y0=2,dl,d2,d3,d4;scanf(%f,%f,&x,&y);dl=(x-xO)*(x-xO)+(y-yO)*(y-yO);d2=(x-xO)*(x-xO)+(y+yO)*
14、(y+yO);d3=(x+xO)*(x+xO)+(y-yO)*(y-yO);d4=(x+xO)*(x+xO)+(y+yO)*(y+yO);if(dll&d2l&d3l&d4l)h=0;printf(h=%d,h);)第五章循环控制5.1main()int a,b,numl,num2,temp;scanf(%d,%d,/,&numl,&num2);if(numl=a&c=A Z)letters+;else if(c=)space+;else if(c=O&c=9)digit+;else other+;)printf(letters=%dnspace=%dndigit=%dnother=%dn”,
15、1etters,space,digit,other);)5.3main()int a,n,count=l,sn=0,tn=0;scanf(,%d,%d,&a,&n);while(count=n)tn+=a;sn+=tn;a*=10;+count;printf(a+aa+aaa+=%dn”,sn);5.4main()float n,s=0,t=l;for(n=l;n=20;n+)t*=n;s+=t;)printf(s=%en”,s);)5.5main()int Nl=100,N2=50,N3=10;flo at k;flo at sl=0,s2=0,s3=0;for(k=l;k=Nl;k+)sl
16、+=k;for(k=l;k=N2;k+)s2+=k*k;for(k=l;k=N3;k+)s3+=l/k;p rin tf(,s=%8.2fn”,sl+s2+s3);)5.6main()int i,j,k,n;for(n=100;n1000;n+)i=n/100;j=n/10-i*10;k=n%10;if(i*100+j*10+k=i*i*i+j*j*j+k*k*k)printf(n=%dn”,n);)5.7ttdefine M 1000main()int kO,kl,k2,k3,k4,k5,k6,k7,k8,k9;int i,j,n,s;for(j=2;j=M;j+)n=0;s=j;for(i
17、=l;il)printf%d”,kO,kl);if(n2)printf(,%d”,k2);if(n3)printf k3);if(n4)printf(,%d”,k4);if(n5)printf(,%d”,k5);if(n6)printf(,%d”,k6);if(n7)printf(,%d”,k7);if(n8)printf(,%d”,k8);if(n9)printf%dn”,k9);)main()static int k10;int i,j,n,s;for(j=2;j=1000;j+)n=-l;s=j;for(i=l;i j;i+)if(j%i)=O)n+;s=s-i;kn=i;)if(s=0
18、)printf(,/j=%dn,/,j);for(i=0;in;i+)printf(%d,k i);printf(%dn,kn);)5.8main()int n,t,number=20;float a=2;b=l;s=0;for(n=l;n=number;n+)s=s+a/b;t=a,a=a+b,b=t;)printf(s=%9.6fn,s);)5.9main()float sn=100.0,hn=sn/2;int n;for(n=2;n0)x l=(x 2+l)*2;x 2=x l;day一;)p r in tf(x l=%d n,x l);)5.11#in cl ude,zm ath.hm
19、 ain ()fl o at a,x n O,x n l;scan f&a);x n 0=a/2;x n l=(x n O+a/x n O)/2;dox n O=x n l;x n l=(x n O+a/x n O)/2;whil e(fab s(x n O-x n l)=l e-5);p r in tf Ca-%5.2f n,x n l=%8.2f n”,a,x n l);)5.12#in cl ude,zin ath.hm ain ()fl o at x,x O,f,fl;x=l.5;dox O=x;f=(2*x 0-4)*x 0+3)*x 0-6;f1=(6*x 0-8)*x 0+3;x
20、=x O-f/f1;)whil e(fab s(x-x O)=l e-5);p r in tf(z,x=%6.2f n,x);5.13#in cl ude,zm ath.hm ain ()fl o at x O,x l,x 2,fx O,fx l,fx 2;doscan f(f,%f”,&x l,&x 2);fx l=x l*(2*x l-4)*x l+3)-6;fx 2=x 2*(2*x 2-4)*x 2+3)-6;)whil e (fx l*fx 20);dox 0=(x l+x 2)/2;fx O=x O*(2*x 014)*x 0+3)-6;if(fx 0*fx l)=l e-5);p
21、 r in tf(x 0=%6.2f n,x O);)5.14m ain ()in t i,j,k;fo r (i=O;i=3;i+)fo r(j=0;j=2-i;j+)p r in tf(“);fo r(k=0;k=2*i;k+)p r in tf(*);p r in tf(n);)fo r(i=0;i=2;i+)fo r(j=0;j=i;j+)p r in tf();fo r (k=0;k=4-2*i;k+)p r in tf(*);p r in tf(n);)5.15m ain ()char i,j,k;fo r (i=,x;i=,z,;i+)fo r(j=x ;j=z;j+)if(i!
22、=j)fo r (k=,x ;k=z;k+)if(i!=k&j!=k)if(i!=x&k!=x&k!=z)p r in tf(n a-%c tb 一%c tc一%c n”,i,j,k);)第 六 章 数组6.1ttin cl ude ttde fin e N 101m ain ()in t i,j,l in e,a N;fo r (i=2;iN;i+)a i=i;fo r (i=2;isq r t(N);i+)fo r (j=i+l;jN;j+)if(ai!=0&aj!=0)if(aj%ai=O)aj=O;printf(n);for(i=2,line=0;iN;i+)if(ai!=0)prin
23、tf C,%5d,,a i);line+;)if(line=10)printf(n);line=0;)6.2ttdefine N 10main()int i,j,min,temp,aN;for(i=0;iN;i+)scanf&ai);for(i=0;iN-l;i+)min=i;for(j=i+l;jaj)min=j;temp=ai;ai=amin;amin=temp;for(i=0;iN;i+)printf(%5d”,a i);)6.3main()float a33,sum;int i,j;for(i=0;i3;i+)for(j=0;j3;j+)scanf&sum);ai j=sum;for(
24、i=0;ie n d)a 10=n um b e r;e l sefo r(i=0;in um b e r)te m p l=a i;a i=n um b e r;fo r(j=i+l;jl l;j+)te m p 2=a j;a j=te m p l;te m p l=te m p 2;)b r e ak;fo r(i=0;il 1;i+)printf(%6d”,a i);)6.5#define N 5main()int aN=8,6,5,4,1),i,temp;for(i=0;iN/2;i+)temp=ai;ai=aN-i-l;aN-i-l=temp;for(i=0;iN;i+)print
25、f(%4d,a i);)6.6#define N 11main()int i,j,aN N;for(i=l;iN;i+)ai i=l;ai 1=1;for(i=3;iN;i+)fo r(j=2;j i;j+)a i j=a i-l j-l+a i-l j ;f o r(i=l;iN;i+)fo r(j=l;j=i;j+)p rin tf(%6d”,a i j );p r in tf(n );)6.7main()int a16 16,i,j,k,p,m,n;P=l;while(p=l)scanf(%d,&n);i f(n!=0)&(n=15)&(n%2!=0)p=0;)f o r(i=l;i=n
26、;i+)for(j=l;j=n;j+)a i j=0;j=n/2+l;a l j=l;for(k=2;k=n*n;k+)i=i-l;j=j+l;if(in)i=i+2;j=jT;)elseif(in)j=l;)if(aij=0)aij=k;elsei=i+2;j=j-l;aij=k;)for(i=l;i=n;i+)for(j=l;j=n;j+)printf C,%3d,,ai j);p rin tf(n );6.8ttdefine N 10ttdefine M 10main()int i,j,k,m,n,flagl,f lag2,aN M,max,maxi,m a x j;scanf(%d,%
27、d,&n,&m);for(i=0;in;i+)for(j=0;jm;j+)scanf(%d”,&ai j);flag2=0;for(i=0;K n;i+)max=ai0;for(j=0;jm;j+)if(maxai j)max=ai j;m axj=j;for(k=0,flagl=l;kakmaxj)flagl=0;if(flagl)printf(na%d%d=%dn”,i,maxj,max);flag2=l;)i f(!flag2)printf(NOT);)6.9#includettdefine N 15main()int i,j,number,top,bott,min,loca,aN,fl
28、ag;char c;for(i=0;i=N;i+)scanf(%d”,&a i);flag=l;while(flag)scanf(%d”,&number);loca=0;top=0;bott=N-l;if(numberaN-l)loca=-l;while(loca-0)&(top=bott)min=(bott+top)/2;if(number=amin)loca=min;printf(,/numbered,loca=%dn,number,loca+1);else if(numberamin)bott=min-l;elsetop=min+l;)if(loca=0|loca=-l)printf(,
29、%d not in tablen,,number);printf(continue Y/N or y/nn);c=getchar();if(c=N|c-n)flag=0;)6.10main()int i,j,uppn,lown,dign,span,othn;char text380;uppn=lown=dign=span=othn=0;for(i=0;i3;i+)gets(texti);for(j=0;j=,A&texti j=,a&text i j=,O&text i j=,9)dign+;else if(text i j=)span+;elseothn+;for(i=0;i3;i+)pri
30、ntf(,%sn,,text i);printf(,uppn=%dn,/,uppn);printf(lown=%dn,lown);printf(dign=%dn,dign);printf(span=%dn,span);printf(,othn=%dn,/,othn);)6.11main()static char a5=*,,,*,,,*,,,*,,,*)int i,j,k;char space;for(i=0;i=5;i+)printf(n);for(j=l;j=3*i;j+)printf space);for(k=0;k=5;k+)printf(%3c,ak);)6.12#includema
31、in()int i,n;char ch80,tran80;gets(ch);i=0;whil e(ch i!=0)if(ch i=A)&(ch i=Z)tr an i=26+64-ch i+1+64;e l se if(ch i=,a)&(ch i=z)tr an i=26+96-ch i+1+96;e l setr an i=ch i;i+;n=i;fo r(i=0;in;i+)p utchar(tr an i);)6.13m ain ()char si 80,s2 40;in t i=0,j=0;scan f(%s,si);scan f s2);whil e (si i!=0)i+;whi
32、l e (s2 j!=0)si i+=s2 j+;si i=,0;p r in tf(,s=%s n,,si);)6.14#in cl ude m ain ()in t i,r e su;char sl 100,s2 100;ge ts(sl);ge ts(s2);i=0;whil e (si i=s2 i)&(sl i!=0)i+;if(si i=,0J&s2 i=0)r e su=0;e l ser e su=sl i-s2 i;p r in tf(sl=%s,s2=%s,r e su=%d n”,si,s2,r e su);)6.15#in cl ude“stdio.hm ain ()c
33、har fr o m 80,to 80;in t i;scan f(%s”,fr o m);fo r(i=0;iv)t=u;u=v;v=t;a=u;b=v;whil e(r=b%a)!=0)b=a;a=r;r e tur n(a);)l cd(u,v,h)in t u,v,h;r e tur n (u*v/h);m ain ()in t u,v,h,1;scan f(%d,%d,&u,&v);h=hcf(u,v);printf(H.C.F=%dn,h);l=lcd(u,v,h);printf(L.C.D=%dn”,1);)7.2ttincludemath.hfloat xl,x2,disc,p
34、,q;greater than zero(a,b)float a,b;xl=(-b+sqrt(disc)/(2*a);x2=(-b-sqrt(disc)/(2*a);)equal_to_zero(a,b)f laot a,b;xl=x2=-b/(2*a);smaller than zero(a,b)float a,b;p=-b/(2*a);q=sqrt(-disc)/(2*a);)main()float a,b,c;scanf C%f,%f,%f,&a,&b,&c);disc=b*b-4*a*c;if(fabs(disc)0)greater_than_zero(a,b);printf(xl=%
35、5.2ftx2=%5.2fn”,xl,x2);)elsesmal ler_than_zero(a,b);printf(xl=%5.2f+%5.2fitx2=%5.2f-%5.2fin,p,q,P,q);)7.3main()int number;s c a n f&n u m b e r);if(prime(number)printf(yes);elseprintf(no);)int prime(number)int number;int flag=l,n;for(n=2;nnumber/2&f1ag=1;n+)if(number%n=0)flag=0;return(flag);)7.4ttde
36、fine N 3int arrayNN;convert(array)int array33;int i,j,t;for(i=0;iN;i+)for(j=i+l;jN;j+)t=arrayij;arrayi j=arrayj i;arrayji=t;)main()int i,j;for(i=0;iN;i+)for(j=0;jN;j+)scanf(,%d,/,&array i j);convert(array);for(i=0;iN;i+)printf(n);for(j=0;jN;j+)p r i n t f a r r a y i j);)7.5main()char str100;scanf s
37、tr);inverse(str);printf(sn”,s tr);in ve r se(str)char str ;char t;in t i,j;fo r(i=0,j=str l e n(str);i0;i一)str i*2=str i;str i*2-l=,;)p r in tf(%s n,str);)7.9in t al p h,digit,sp ace,o the r s;m ain ()char te x t 80;ge ts(te x t);alph=O,digit=O,space=O,others=0;count(text);printf(,nalph=%d,digit=%d,
38、space=%d,others=%dn,/,alph,digit,space,others);)count(str)char str;int i;for(i=0;str i!=,0;i+)if(stri=,a&stri=,z)|(str i=A&stri=,O&str i=,a&c=A&c=Z)return(1);elsereturn(0);)int longest(string)char string;int len=0,i,length=0,flag=l,place,point;for(i=0;ilength)length=len;place=point;len=0;return(plac
39、e);)main()int i;char line100;gets(line);for(i=longest(line);alph(linei);i+)printf lin e i);printf(n);)7.11ttdefine N 10char strN;main()int i,flag;for(flag=l;flag=l;)scanf s tr);if(strlen(str)N)printf(,,input error);elseflag=O;)sort(str);for(i=0;iN;i+)printf(%c”,s tri);)sort(str)char strN;int i,j;cha
40、r t;for(j=l;jN;j+)for(i=0;(istr i+1)t=stri;stri=stri+1;stri+l=t;)7.12#includefloat solut(a,b,c,d)float a,b,c,d;float x=l,xO,f,f l;doxO=x;f-(a*xO+b)*xO+c)*xO+d;f 1=(3*a*x0+2*b)*xO+c;x=xO-f/f1;while(fabs(x-xO)=le-5);return(x);)main()float a,b,c,d;scanf(%f,%f,%f,%r,&a,&b,&c,&d);printf(x=%10.7fn”,solut(
41、a,b,c,d);)7.13main()int x,n;float p();scanf(%d,%d,&n,&x);printf(P%d(%d)=%10.2fn”,n,x,p(n,x);float p(tn,tx)int tn,tx;if(tn=0)return(1);else if(tn-1)return(tx);elsereturn(2*tnT)*tx*p(tnl),tx)-(tn-l)*p(tn-2),tx)/tn);)7.14ttdefine N 10#define M 5float scoreNM;float a_stuN,a_corM;main()int i,j,r,c;float
42、h;float s diff();float highest();r=0;c=l;input stuO;avr_stu();avr_cor();printf(n number class 12345 avr);for(i=0;iN;i+)printf(nN0%2d”,i+1);for(j=0;jM;j+)printf(,z%8.2f”,scorei j);printf(%8.2f,a_stui);printf(,nclassavr,/);for(j=0;j s_diff();)input_stu()int i,j;float x;for(i=0;iN;i+)for(j=0;jM;j+)scan
43、f&x);scoreij=x;av rstu ()int i,j;float s;for(i=0;iN;i+)for(j=0,s=0;jM;j+)s+=scorei j;a_stui=s/5.0;)avr_cor()int i,j;float s;for(j=0;jM;j+)for(i=0,s=0;iN;i+)s+=scorei j;a_corj=s/(float)N;)float highest(r,c)int*r,*c;float high;int i,j;high=score0 0;for(i=0;iN;i+)for(j=0;jhigh)high=scoreij;*r=i+l;*c=j+
44、l;)return(high);)float s_diff()int i,j;float sumx=0.0,sumxn=0.0;for(i=0;iN;i+)sumx+=a_stui*a_stui;sumxn+=a_stui;return(sumx/N-(sumxn/N)*(sumxn/N);)7.15#includettdefine N 10void input e(num,name)int num;char nameN8;int i;for(i=0;iN;i+)scanf&numi);gets(namei);)void sort(num,name)int num;char nameN8;in
45、t i,j,min,tempi;char temp28;for(i=0;iN-l;i+)min=i;for(j=i;jnumj)min=j;templ=numi;numi=nummin;nummin=templ;strcpy(temp2,namei);strcpy(namei,namemin);strcpy(namemin,temp2);)for(i=0;iN;i+)printf(n%5d%10s”,numi,namei);)void search(n,num,name)int n,num;char nameN8;int top,bott,min,loca;loca=0;top=0;bott=
46、N-l;if(nnumN-l)loca=-l;while(loca=0)&(top=bott)min=(bott+top)/2;if(n=nummin)loca=min;printf(,znumber=%d,name=%sn”,n,name 1 oca);)else if(nnummin)bott=min-l;elsetop=min+l;if(loca=0|loca=-l)printf(number=%d is not in tablen”,n);)main()int numN,number,flag,c,n;char nameN8;input e(num,name);sort(num,nam
47、e);for(flag=l;flag;)scanf(d”,&number);search(number,num,name);printf(continue?Y/N!);c=getchar();if(c=,N5|c=,n,)flag=O;)7.16#include#define M A X 1000main()int c,i,flag,flag l;char tMAX;i=0;flag=0;flagl=l;while(c=getchar()!=0&i=O&c=A&c=a&c=O&s i=,a&s i=A&s i=F)n=n*16+s i-A+10;r e tur n (n);)7.17#in c
48、l ude vo id co n ve r t(n)in t n;in t i;if(i=n/10)!=0)co n ve r t(i);p utchar (n%10+5 O);)m ain ()in t n um b e r;scan f&n um b e r);if(n um b e r=3)days+=l;printf(,/days=%dn,/,days);)staticintday_tab13=0,31,28,31,30,31,30,31,31,30,31,30,31int sum day(month,day)int month,day;int i;for(i=l;ic&b+ca&a+
49、cb)printf(,area=%8.2f n”,AREA(a,b,c);elseprintf(input error);)8.4ttdefine LEAP(y)(y%4=0)&(y%100!=0)|(y%400=0)main()int year;scanf&year);if(LEAP(year)printf(yes);elseprintf(no);)8.5printf(,value=%formatt,x);printf(,/value=%formatt,x)jputchar(n);printf(,value=%formatt,,xl)jprintf(,value=%formatt,/,x2)
50、;putchar(n,);输出结果:value=5.OOOOOOormat value=5.OOOOOOormatvalue=3.OOOOOOormat value=8.OOOOOOormat8.6#define PR printf#define NL nttdefine Fs%fttdefine F%6.2fttdefine Fl F NLttdefine F2 F t F NLttdefine F3 F t F t F NLmain()float a,b,c;scanf(Fs,&a);scanf(Fs,&b);scanf(Fs,&c);PR(NL);PR(Fl,a);PR(Fl,b);PR