1、2.12(1)24 (2)10 (3)60 (4)0 (5)0 (6)0第三章3.4int 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=c2=ba=%2d b=%2d c=%2dn,a,b,c);x=%8.6f,y=%8.6f,z=%9.6fn,x,y,z);x+y=%5.2f y+z=%5.2f z+x=%5.2fn,x+y,y+z,z+x);u=%6ld n=%9ldn,u,n);c1=%cor %d(ASCII)n,c1,c1);,c
2、2,c2);3.557 5 767.856400,-789.123962 67.86 -789.12,67.856400,-789.123962,67.856400,-789.1239626.785640e+001,-7.89e+002A,65,101,411234567,4553207,d68765535,177777,ffff,-1COMPUTER, COM3.6a=3 b=7/x=8.5 y=71.82/c1=A c2=a/3.7 10 20Aa1.5 -3.75 +1.4,67.8/(空3)10(空3)20Aa1.5(空1)-3.75(空1)(随意输入一个数),67.8回车3.8flo
3、at pi,h,r,l,s,sq,sv,sz; pi=3.1415926;input r,hn%f,%fr,&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;l=%6.2fn,l);s=%6.2fn,s);sq=%6.2fn,sq);vq=%6.2fn,sv);vz=%6.2fn,sz);3.9float c,f;%ff); c=(5.0/9.0)*(f-32);c=%5.2fn,c);3.10#includestdio.hchar c1,c2;%c,%cc1,&c2); putchar(c1); pu
4、tchar(c2);%c%cn第四章4.3(1)0 (2)1 (3)1 (4)0 (5)14.4 if(ab) if(bc)max=%dn else,b); else if(ab)?a:b; max=(ctemp)?c:temp; 4.5int x,y;%dx); if(x1)y=x; else if(x=0&score9999) place=5; else if(num999) place=4;99) place=3;9) place=2; else place=1;place=%dn,place); ten_thousand=num/10000; thousand=(num-ten_tho
5、usand*10000)/1000; hundred=(num-ten_thousand*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) case 5:printf(%d,%d,%d,%d,%dn,ten_thousand,thousand,hundred,ten,indiv);,indiv,ten,hundred,tho
6、usand,ten_thousand); break;%d,%d,%d,%dn,thousand,hundred,ten,indiv);,indiv,ten,hundred,thousand);%d,%d,%dn,hundred,ten,indiv);,indiv,ten,hundred);%d,%dn,ten,indiv);,indiv,ten);%dn,indiv);4.8long i; float bonus,bon1,bon2,bon4,bon6,bon10; bon1=100000*0.1; bon2=bon1+100000*0.075; bon4=bon2+200000*0.05;
7、 bon6=bon4+200000*0.03; bon10=bon6+400000*0.015;i); if(i=1e5)bonus=i*0.1; else if(i10)branch=10; switch(branch) case 0:bonus=i*0.1;bonus=bon1+(i-100000)*0.075;bonus=bon2+(i-200000)*0.05;bonus=bon4+(i-400000)*0.03; case 7 case 9:bonus=bon6+(i-600000)*0.015; case 10:bonus=bon10+(i-1000000)*0.01;4.9int
8、 t,a,b,c,d;%d,%d,%d,%dc,&d); if(ab)t=a;a=b;b=t;c)t=a;a=c;c=t;d)t=a;a=d;d=t; if(bc)t=b;b=c;d)t=b;b=d; if(cd)t=c;c=d;%d %d %d %dn,a,b,c,d);4.10int h=10; float x,y,x0=2,y0=2,d1,d2,d3,d4;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+x
9、0)+(y+y0)*(y+y0); if(d11&d2d3d41)h=0;h=%d,h);第五章 循环控制5.1int a,b,num1,num2,temp;%d,%dnum1,&num2); if(num1cZ) letters+; else if(c= )space+; else if(c09)digit+; else other+;letters=%dnspace=%dndigit=%dnother=%dn,letters,space,digit,other);5.3int a,n,count=1,sn=0,tn=0;n); while(count=n) tn+=a; sn+=tn; a
10、*=10; +count;a+aa+aaa+.=%dn,sn);5.4float n,s=0,t=1; for(n=1;n=20;n+) t*=n; s+=t;s=%en5.5int N1=100,N2=50,N3=10; float k; float s1=0,s2=0,s3=0; for(k=1;k=N1;k+)s1+=k;=N2;k+)s2+=k*k;=N3;k+)s3+=1/k;s=%8.2fn,s1+s2+s3);5.6int i,j,k,n; for(n=100;1000; i=n/100; j=n/10-i*10; k=n%10; if(i*100+j*10+k=i*i*i+j*
11、j*j+k*k*k)n=%dn,n);5.7#define M 1000int 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(,k0,k1);2)printf(,%d,k2);3)printf(,k3);4)printf(,k4);5)printf(,k5);6)printf(,k6);7)printf(,k7);8)printf(,k8);9)printf(,%dn,k9);static int k10;=1000; n=-1; kn=i; for(i=0;n;%
12、d,ki);,kn);5.8int n,t,number=20; float a=2;b=1;s=0;=number; s=s+a/b; t=a,a=a+b,b=t;s=%9.6fn5.9float sn=100.0,hn=sn/2; int n; for(n=2;=10; sn=sn+2*hn; hn=hn/2;sn=%fnhn=%fn,hn);5.10int day,x1,x2; day=9; x2=1; while(day0) x1=(x2+1)*2; x2=x1; day-;x1=%dn,x1);5.11math.hfloat a,xn0,xn1;a); xn0=a/2; xn1=(x
13、n0+a/xn0)/2; do xn0=xn1; while(fabs(xn0-xn1)=1e-5);a=%5.2fn,xn1=%8.2fn,a,xn1);5.12float x,x0,f,f1; x=1.5; x0=x; f=(2*x0-4)*x0+3)*x0-6; f1=(6*x0-8)*x0+3; x=x0-f/f1; while(fabs(x-x0)x=%6.2fn,x);5.13float x0,x1,x2,fx0,fx1,fx2;x1,&x2); fx1=x1*(2*x1-4)*x1+3)-6; fx2=x2*(2*x2-4)*x2+3)-6; while(fx1*fx20); x
14、0=(x1+x2)/2; fx0=x0*(2*x0-4)*x0+3)-6; if(fx0*fx1)x0=%6.2fn,x0);5.14int i,j,k;=3; for(j=0;=2-i; for(k=0;=2*i;k+)*=2;=i;=4-2*i;5.15char i,j,k; for(i=x for(j= if(i!=j) for(k=k&j!=k)k!na-%ctb-%ctc-%cn,i,j,k);第六章 数组6.1 #include #define N 101 main() int i,j,line,aN; for (i=2;N;i+) ai=i;sqrt(N); for (j=i+1; if(ai!=0 & aj! if (aj%ai=0) aj=0; for (i=2,line=0; if(ai! printf(%5d,ai); line+; if(line=10) line=0;6.2#define N 10int i,j,min,temp,aN;ai);N-1; min=i; for(j=i+1; if(aminaj)min=j; t
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1