《C程序设计(第三版)课后习题答案_谭浩强著.pdf》由会员分享,可在线阅读,更多相关《C程序设计(第三版)课后习题答案_谭浩强著.pdf(46页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、C程 序 设 计(第三版)习 题 答 案(1-6 章)谭浩强著习题答案第一章1.5#include void main()(printf(*n Very good!n*n);)1.6(法 一)include main()(int a,b,c,max;scanf(%d,%d,%d,&a,&b,&c);max=(ab)?a:b;max=(maxc)?max:c;pri ntf(max=%dn,max);(法二)main()(int a,b,c,max;scanf(%d,%d,%d,&a,&b,&c);if(ab&ac)max=a;else if(bc)max=b;elsemax=c;pri ntf
2、(max=%dn,max);#include void main()(int max(int x,int y,int z);int a,b,c,d;scanf(%d,%d,%d,&a&b,&c);d=max(a,b,c);printf(max=%dn,d);)int max(int x,int y,int z)(int A,B;if(xy)A=x;else A=y;if(zA)B=z;else B=A;return(B);第三章3 3(1)(10)10=(12)8=(a)16(2)(32)10=(40)8=(20)16(3)(75)10=(113)8=(4b)16(4)(-617)10=(17
3、6627)8=(fd97)16(-111)10=(177621)8=(ff91)16(6)(2483)10=(4663)8=(963)16(7)(-28654)10=(110022)8=(9012)16(8)(21003)10=(51013)8=(520b)163.6aabb(8)cc(8)abc(7)AN3.7main()char c1=C,c2=,h,c3=i,c4=n,c5=a;c1+=4,c2+=4,c3+=4,c4+=4,c5+=4;printf(%c%c%c%c%cn,c1,c2,c3,c4,c5);)3.8main()int c1,c2;c1=97;c2=98;prir)tf(%
4、c%c,c1,c2);)3.9(1)=2.5(2)=3.53.109,11,9,103.12(1)24(2)10(3)60(4)0(5)0(6)0第四章4.4main()int a,b,c;long int u,n;float x,y,z;char c1,c2;a=3;b=4;c=5;x=1.2;y=2.4;z=-3.6;u=51274;n=128765;c1=a;c2-b;printf(n);printf(a=%2d b=%2d c=%2dn,a,b,c);printf(x=%8.6f,y=%8.6f,z=%9.6fn,x,y,z);printf(x+y=%5.2f y+z=%5.2f z+
5、x=%5.2fn,x+y,y+z,z+x);printf(u=%6ld n=%9ldn,u,n);printf(c1=%cor%d(ASCII)n,c1,c1);printf(c2=%cor%d(ASCII)n,c2,c2);)4.5575767.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,COMPUTER,COM4
6、.6a=3 b=7/x=8.5 y=71.82/c1=A c2=a/4.710 20Aa1.5-3.75+1.4,67.8/(空3)10(空 3)20Aa1.5(空 1)375(空 1)(随意输入一个数),67.8回车4.8main()float pi,h,r,l,s,sq,sv,sz;pi=3.1415926;printf(input r,hn);scanf(%f,%f,&r,&h);l=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(l=%6.2fn,l);printf(s=%6.2fn,s);print
7、f(sq=%6.2fn,sq);printf(vq=%6.2fn,sv);printf(vz=%6.2fn,sz);4.9main()float c,f;scanf(%f,&f);c=(5.0/9.0)*(f-32);printf(c=%5.2fn,c);)4.10#includestdio.hmain()char c1,c2;scanf(%c,%c,&c1,&c2);putchar(d);putchar(c2);prir)tf(n);printf(%c%cn,c1,c2);)第五章5.3(1)0(2)1(3)1(4)0(5)15.4main()int a,b,c;scanf(%d,%d,%d
8、,&a,&b,&c);if(ab)if(bc)printf(max=%dn,c);elseprintf(max=%dn,b);else if(ab)?a:b;max=(ctemp)?c:temp;printf(max=%d,max);5.5main()int x,y;scanf(%d,&x);if(x1)y=x;else if(x=0&score 9 9 9 9)place=5;else if(num 9 9 9)place=4;else if(num 9 9)place=3;else if(num 9)place=2;else place=1;printf(place=%dn,place);
9、ten_thousand=num/10000;thousand=(num-ten_thousand*10000)/1000;hundred=(num-ten_?housand*10000-thousand*1000)/100;ten=(num-ten_thousand*10000-thousand*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,hun
10、dred,ten,indiv);printf(%d,%d,%d,%d,%dn,indiv,ten,hundred,thousand,ten_thousand);break,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);printf(%d,%d,%dn,indiv,ten,hundred);breakcase 2:printf(%d,%dn,
11、ten,indiv);printf(%d,%dn,indiv,ten);break case 1:printf(%dn,indiv);printf(%dn,indiv);5.8main()long i;float bonus,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;scanf(%ld,&i);if(i=1 e5)bonus=i*0.1;else if(i=2e5)bonu
12、s=bon1+(1-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(i 10)branch=10;switch(branch)case 0:bonus=i*0.1;break;case 1:bonus=bon1+(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;bre
13、ak;case 6:case 7case 8:case 9:bonus=bon6+(i-600000)*0.015;break;case 10:bonus=bon10+(1-1000000)*0.01;)printf(bonus=%10.2f,bonus);4.9main()int t,a,b,c,d;scanf(%d,%d,%d,%d,&a,&b,&c,&cl);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(%
14、d%d%d%dn,a,b,c,d);)5.10main()int 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+xO)*(x+xO)+(y+yO)*(y+yO);if(d 1 1&d21&d3 1&d4 1)h=0;printf(h=%d,h);:六 章 循 环 控 制6.1main()int a,b,num1,num2,temp;s
15、canf(%d,%d,&num1,&num2);if(num1=a&c=A&c=0&c=9)digit+;else other+;printf(letters=%dnspace=%dndigit=%dnother=%dn,letters,space,digit,other);6.3main()int a,n,count=1,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);)6.4main()float n,s=0,t=1;for(n=1;n=20;n+)
16、t*=ns+=t)printf(s=%en,s);)6.5main()int N1=100,N2=50,N3=10;float k;float s1=0,s2=0,s3=0;for(k=1;k=N1;k+)s1+=k;for(k=1;k=N2;k+)s2+=k*k;for(k=1;k=N3;k+)s3+=1/k;printf(s=%8.2fn,s1+s2+s3);6.6main()int i,j,k,n;for(n=100;n1000;n+)i=n/100;j=n/1O-i*1O;k=n%10;if(i*1 OO+j*1O+k=i*i*i+j*j*j+k*k*k)printf(n=%dn,n)
17、;)6.7#define M 1000main()int k0,k1,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=1;i1)printf(%d,%d,kO,k1);if(n2)printf(,%d,k2);if(n3)printf(,%d,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()
18、static int k10;int i,j,n,s;for(j=2;j=1000;j+)n=-1;s=j;for(i=1;ij;i+)if(j%i 尸=0)n+;s=s-i;kn=i;)if(s=0)printf(j=%dn,j);for(i=0;in;i+)printf(%d,ki);printf(%dn,kn);6.8main()int n,t,number=20;float a=2;b=1;s=0;for(n=1;n=number;n+)s=s+a/b;t=a,a=a+b,b=t;)printf(s=%9.6fn,s);)6.9main()float sn=100.0,hn=sn/2;
19、int n;for(n=2;n0)x1=(x2+1)*2;x2=x1;day-;printf(x1=%dn,x1);6.11#includemath.hmain()float a,xn0,xn1;scanf(%f,&a);xnO=aExn1=(xn0+a/xn0)/2;doxn0=xn1;xn1=(xn0+a/xn0)/2;while(fabs(xn0-xn1)=1e-5);printf(a=%5.2fn,xn1=%8.2fn,a,xn1);6.12#includemath.hmain()float x,x0,f,f1;x=1.5;dox0=x;f=(2*x0-4)*x0+3)*x0-6;f1
20、=(6*x0-8)*x0+3;x=x0-f/f1;)while(fabs(x-x0)=1e-5);printf(x=%6.2fn,x);6.13#includemath.hmain()float x0,x1,x2,fx0,fx1,fx2;doscanf(%f,%f,&x1,&x2);fx1=x1*(2*x1-4)*x1+3)-6;fx2=x2*(2*x2-4)*x2+3)-6;while(fx1*fx20);dox0=(x1+x2)/2;fx0=x0*(2*x0-4)*x0+3)-6;if(仅 0*fx1)=1e-5);printf(x0=%6.2fn,x0);)6.14main()int i
21、,j,k;for(i=0;i=3;i+)for(j=0;j=2-i;j+)prin tff);for(k=0;k=2*i;k+)printf(*);printf(n);)for(i=0;i=2;i+)for(j=0;j=i;j+)printf();for(k=0;k=4-2*i;k+)printf(*);printf(n);6.15main()char i,j,k;for(i-x;i=z;i+)for(j=x;j=z;j+)if(i!=j)for(k=x;k=z;k+)if(i!=k&j!=k)if(i!=x&k!=x&k!=z)printf(na-%ctb-%ctc-%cn,i,j,k);第
22、七章数组7.1include#define N 101main()int i,j,line,aN;for(i=2;iN;i+)ai=i;for(i=2;isqrt(N);i+)for(j=i+1;jN;j+)if(ai!=0&aj!=0)if(aj%ai=0)aU=0;printf(n);for(i=2,line=0;iN;i+)if(ai!=0)printf(%5d,ai);line+;if(line=10)printf(n);line=0;7.2#define N 10main()int i,j,min,temp,aN;for(i=0;iN;i+)scanf(%d,&ai);for(i=0
23、;iN-1;i+)min=i;for(j=i+1;jaj)min=j;temp=ai;ai=amin;amin=temp;for(i=0;iN;i+)printf(%5d,ai);7.3main()float a33,sum;int i,j;for(i=0;i3;i+)for(j=0;j3;j+)scanf(%f,&sum);ai0=sum;)for(i=0;iend)a10=number;elsefor(i=0;inumber)tempi=ai;ai=number;for(j=i+1;j11;j+)temp2=aj;aj=temp1;tempi=temp2;)break;)for(i=0;i
24、11;i+)printf(%6d,ai);7.5#define N 5main()int aN=8,6,5,4,1,i,temp;for(i=0;iN/2;i+)temp=ai;ai=aN-i-1;aN-i-1=temp;)for(i=0;iN;i+)printf(%4d,ai);7.6#define N 11main()int i,j,aNN;for(i=1;iN;i+)aii=1;ai1=1;for(i=3;iN;i+)for(j=2;ji;j+)aiU=ai-1D-1+ai-1Dl;for(i=1;iN;i+)for(j=1;j=i;j+)printf(%6d,aij);printf(n
25、);7.7main()int a1616,i,j,k,p,m,n;p=1;while(p=1)scanf(%d,&n);if(n!=0)&(n=15)&(n%2!=0)p=0;for(i=1;i=n;i+)for(j=1;j=n;j+)aij=O;j=n/2+1;a1j=1;for(k=2;k=n*n;k+)i=i-1;j=j+1;if(in)i=i+2;j=j-1;elseif(in)j=1;)if(aij=O)aiU=k;elsei=i+2;j=j-1;aiD=k;)for(i=1;i=n;i+)for(j=1;j=n;j+)printf(%3d,aiU);printf(n);)7.8#d
26、efine N 10#define M 10main()int i,j,k,m,n,flag1,flag2,aNM,max,maxi,maxj;scanf(%d,%d,&n,&m);for(i=0;in;i+)for(j=0;jm;j+)scanf(%d,&aij);flag2=0;for(i=0;in;i+)max=ai0;for(j=0;jm;j+)if(maxaij)max=ai0J;maxj=j;for(k=0,flag1=1;kakmaxj)flag1=0;if(flagl)printf(na%d%d=%dn,i,maxj,max);flag2=1;if(!flag2)printf(
27、NOT);7.9#ir)clude#define N 15main()int i,j,number,top,bott,min,loca,aN,flag;char c;for(i=0;i=N;i+)scanf(%d,&ai);flag=1;while(flag)scanf(%d,&number);loca=0;top=0;bott=N-1;if(numberaN-1)loca=_*1*while(loca=0)&(top=bott)min=(bott+top)/2;if(number=amin)loca=min;printf(number=%d,loca=%dn,number,loca+1);e
28、lse if(numberamin)bott=min-1;elsetop=min+1;if(loca=0|loca=-1)printf(%d not in tablen,number);printf(continue Y/N or y/nn);c=getchar();if(c=N|c=n)flag=O;7.10main()int i,j,uppn,lown,dign,span,othn;char text380;uppn=lown=dign=span=othn=0;for(i=0;i3;i+)gets(text。);for(j=0;j=A&textij=a&textij=0&textij=9)
29、dign+;else if(textij=)span+;elseothn+;)for(i=0;i3;i+)printf(%sn,texti);printf(uppn=%dn,uppn);printf(lown=%dn,lown);printf(dign=%dn,dign);printf(span=%dn,span);printf(othn=%dn,othn);)7.11main()static char a5=*,int i,j,k;char space=for(i=0;i=5;i+)printf(n);for(j=1;j=3*i;j+)printf(%1c,space);for(k=0;k=
30、5;k+)printf(%3c,ak);7.12#includemain()int i,n;char ch80,tran80;gets(ch);i=0;while(chi!=O)if(chi=A)&(chi=a)&(chi=,z)trani=26+96-chi+1+96;elsetrani=chi;i+;)n=i;for(i=0;in;i+)putchar(trani);)7.13main()chars180,s240;int i=O,j=O;scanf(%s,s1);scanf(%s,s2);while(s1i!=0)i+;while(s2j!=,O,)s1i+=s20+;s1i=0;pri
31、ntf(s=%sn,s1);7.14#includemain()int i,resu;chars1100,s2100;gets(s1);gets(s2);i=0;while(s1 i=s2i)&(s1 i!=O)i+;if(s1i=0&s2i=,0)resu=0;elseresu=s1i-s2i;printf(s1=%s,s2=%s,resu=%dn,s1,s2,resu);)7.15#includestdio.hmain()char from80,to80;int i;scanf(%s,from);for(i=0;iv)t=u;u=v;v=t;a=u;b=v;while(r=b%a)!=O)
32、b=a;a=r;return(a);lcd(u,v,h)int u,v,h;return(u*v/h);mair)()int u,v,h,l;scanf(%d,%d,&u,&v);h=hcf(u,v);printf(H.C.F=%dn,h);l=lcd(u,v,h);printf(L.C.D=%dn,l);8.2#includemath.hfloat x1,x2,disc,p,q;greater_than_zero(a,b)float a,b;x1=(-b+sqrt(disc)/(2*a);x2=(-b-sqrt(disc)/(2*a);equal_to_zero(a,b)flaot a,b;
33、x1=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(%f,%f,%f,&a,&b,&c);disc=b*b-4*a*c;if(fabs(disc)0)greater_than_zero(a,b);printf(x1=%5.2ftx2=%5.2fn,x1,x2);)elsesmaller_than_zero(a,b);printf(x1=%5.2f+%5.2fitx2=%5.2f-%5.2fin,p,q,p,q);8.3main()int nu
34、mber;scanf(%d,&number);if(prime(number)printf(yes);elseprintf(no);int prime(number)int number;int flag=1,n;for(n=2;nnumber/2&flag=1;n+)if(number%n=O)flag=0;return(flag);)8.4#define N 3int arrayNN;convert(array)int array33;intfor(i=0;iN;i+)for(j=i+1;jN;j+)t=arrayi0;arrayij=arrayji;array ji=t;main()in
35、t i,j;for(i=0;iN;i+)for(j=0;jN;j+)scanf(%d,&arrayij);convert(array);for(i=0;iN;i+)printf(n);for(j=0;jN;j+)printf(%5d,arrayij);)8.5main()char str100;scanf(%s,str);inverse(str);printf(%sn,str);inverse(str)char str;char t;int i,j;for(i=0,j=strlen(str);i0;i-)stri*2=stri;stri*2-1=)printf(%sn,str);8.9int
36、alph,digit,space,others;main()char text80;gets(text);alph=0,digit=0,space=0,others=0;count(text);printf(nalph=%d,digit=%d,space=%d,others=%dn,alph,dig it,space,others);count(str)char str;int i;for(i=0;stri!=0;i+)if(stri=a&stri=,A,&stri=0&stri=,a&c=,A,&c=Z)return(1);elsereturn(O);int longest(string)c
37、har stringQ;int len=0,i,length=0,flag=1,place,point;for(i=0;ilength)length=len;place=point;len=O;return(place);main()int i;char line100;gets(line);for(i=longest(line);alph(linei);i+)printf(%c,linei);printf(n);8.11#define N 10char strN;main()int i.flag;for(flag=1;flag=1;)scanf(%s,str);if(strlen(str)N
38、)printf(input error);elseflag=0;)sort(str);for(i=0;iN;i+)printf(%c,stri);sort(str)char strN;int i,j;char t;for(j=1;jN;j+)for(i=0;(istri+1)t=strij;stri=stri+1;stri+1=t;8.12#includefloat solut(a,b,c,d)float a,b,c,d;float x=1,x0,f,f1;doxO=x;f=(a*xO+b)*xO+c)*xO+d;f1=(3*a*x0+2*b)*x0+c;x=x0-f/f1;while(fab
39、s(x-xO)=1 e-5);return(x);)main()float a,b,c,d;scanf(%f,%f,%f,%r,&a,&b,&c,&d);printf(x=%10.7fn,solut(a,b,c,d);8.13main()int x,n;float p();scanf(%d,%d,&n)&x);printf(P%d(%d)=%10.2fn,nIx,p(n,x);float p(tn,tx)int tn,tx;if(tn=O)return(1);else if(tn=1)return(tx);elsereturn(2*tn-1)*tx*p(tn-1),tx)-(tn-1)*p(t
40、n-2),tx)/tn);8.14#define N 10#define M 5float scoreNM;float a_stuN,a_corM;main()int i,j,r,c;float h;float s_diff();float highest();r=0;c=1;input_stu();avr_stu();avr_cor();prir)tf(n number class 1 2 3 4 5 avr);for(i=0;iN;i+)printf(nNO%2d,i+1);for(j=0;jM;j+)printf(%8.2f,scoreij);printf(%8.2f,a_stui);p
41、rintf(nclassavr);for(j=0;jM;j+)printf(%8.2f,a_corj);h=highest(&r,&c);printf(nn%8.2f%d%dn,h,r,c);printf(n%8.2fn,s_diff();input_stu()int i,j;float x;for(i=0;iN;i+)for(j=0;jM;j+)scanf(%f,&x);scoreij=x;avr_stu()int i,j;float s;for(i=0;iN;i+)for(j=0,s=0;jM;j+)s+=scoreij;a_stui=s/5.0;)avr_cor()inti.j;floa
42、t s;for(j=0;jM;j+)for(i=0,s=0;iN;i+)s+=scoreij;a_corj=s/(float)N;)float highest(r,c)int*r,*c;float high;int i,j;high=score00;for(i=0;iN;i+)for(j=0;jhigh)high=scoreij;*r=i+1;*c=j+1;)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
43、/N-(sumxn/N)*(sumxn/N);)8.15#include#define N 10void input_e(num,name)int num;char nameN8;int i;for(i=0;iN;i+)scanf(%d,&numi);gets(namei);)void sort(num,name)int num;char nameN8;int i,j,min,tempi;char temp28;for(i=0;iN-1;i+)min=i;for(j=i;jnumj)min=j;tempi=numi;numi=nummin;nummin=temp1;strcpy(temp2,n
44、amei);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=N-1;if(nnumN-1)loca=_1*while(loca=0)&(top=bott)min=(bott+top)/2;if(n=nummin)loca=min;printf(number=%d,name=%sn,n,nameloca);
45、else if(nnummin)bott=min-1;elsetop=min+1;)if(loca=0|loca=-1)printf(number=%d is not in tablen,n);main()int numN,number,flag,c,n;char nameN8;input_e(num,name);sort(num,name);for(flag=1;flag;)scanf(%d,&number);search(number,num,name);printf(continue?Y/N!);c=getchar();if(c=N|c=n)flag=O;8.16#include#def
46、ine MAX 1000main()int c,i,flag,flag1;chartfMAX;i=0;flag=0;flag1=1;while(c=getchar()!=0&i=0&c=A&c=a&c=0&si=a&si=A&si=F)n=n*16+si-A+10;return(n);8.17#ir)cludevoid convert(n)int n;int i;if(i=n/10)!=0)convert(i);putchar(n%10+0);)main()int number;scanf(%d,&number);if(number=3)days+=1;printf(days=%dn,days
47、);)static int day_tab13=0,31,28,31,30,31,30,31,31,30,31,30,31int sum_day(month,day)int monlh.day;int i;for(i=1;ic&b+ca&a+cb)printf(area=%8.2fn,AREA(a,b,c);elseprintf(input error);9.4#define LEAP(y)(y%4=0)&(y%100!=0)|(y%400=0)main()int year;scanf(%d,&year);if(LEAP(year)printf(yes);e l-intf(no);)8.5pr
48、intf(value=%formatt,x);printf(va lue=%formatt,x);putchar(n);printf(value=%formatt,x1);printf(value=%formatt,x2);putchar(n);输由结果:value=5.000000ormat value=5.000000ormatvalue=3.000000ormat value=8.000000ormat9.6#define PR printf#define NL n#define Fs%f#define F%6.2f#define F1 F NL#define F2 F t F NL#d
49、efine F3 F t F t F NLmain()float a,b,c;scanf(Fs,&a);scanf(Fs,&b);scanf(Fs,&c);PR(NL);PR(F1,a);PR(F1,b);PR(F1,c);PR(NL);PR(F2,a,b);PR(F1,c);PR(NL);PR(F3,a,b,c);)9.7/*format.h 文件*/#define DIGIT(d)printf(%dn,d)#define FLOAT(f)printf(%8.2fn,f)#define STRING(s)printf(%sn,s)/*用户文件*/#includeformat.hmain()i
50、nt d,num;float f;char s80;scanf(%d,&num);switch(num)case 1:scanf(%d,&d);DIGIT(d);break;case 2:scanf(%f,&f);FLOAT(f);break;case 3:scanf(%s,s);STRING(s);break,default:printf(error);9.8main()int a,b,c;scanf(%d,%d,%d,&a,&b,&c);printf(max=%dn,max(a,b,c);)max(a,b,c)int a,b,c;int t;t=xy?x:y;return(tz?t:z);