您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 西工大C语言POJ习题答案
一.1.第一季10题全(注:第五题问题已经解决,确认AC!)#includestdio.hintmain(){inta,b,sum;scanf(%d%d,&a,&b);sum=a+b;printf(%d\n,sum);return0;}2.#includestdio.h#definePI3.1415926intmain(){doubler,h,l,s,sq,vq,vz;scanf(%lf%lf,&r,&h);l=2*PI*r;s=PI*r*r;sq=4*PI*r*r;vq=4*PI*r*r*r/3;vz=s*h;printf(%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n,l,s,sq,vq,vz);return0;}3.#includestdio.hintmain(){inta,b,c;doubled,e;scanf(%d%d%d,&a,&b,&c);d=a+b+c;e=d/3;printf(%lf\n%lf\n,d,e);return0;}4.#includestdio.hintmain(){inta,b,c;scanf(%d%d%d,&a,&b,&c);if(ab)a=b;if(ac)a=c;printf(%d\n,a);return0;}5.#includestdio.hintmain(){inti=0,j=0,k=1;chara[6];while((a[i]=getchar())!='\n'){i++;}for(;i0;i--){if(a[j]==a[i-1]){j++;continue;}else{k=0;break;}}if(k==1)printf(yes\n);elseprintf(no\n);}6.#includestdio.hintmain(){doublea,c;scanf(%lf,&a);switch((int)a/10){case0:c=a*0.1;break;case1:c=(a-10)*0.075+10*0.1;break;case2:case3:c=(a-20)*0.05+10*0.075+10*0.1;break;case4:case5:c=(a-40)*0.03+20*0.05+10*0.075+10*0.1;break;case6:case7:case8:case9:c=(a-60)*0.015+20*0.03+20*0.05+10*0.075+10*0.1;break;default:c=(a-100)*0.01+40*0.015+20*0.03+20*0.05+10*0.075+10*0.1;}printf(%lf\n,c);return0;}7.#includestdio.hintmain(){doublea,b,c;scanf(%lf,&a);c=(int)a;if(ac)a=c+1;if(a15)b=(a-15)*2.1+7+13*1.5;else{if(a2)b=(a-2)*1.5+7;elseb=7;}printf(%lf\n,b);return0;}8.#includestdio.hintmain(){inta,b,c,e,f=30,g=31,n;scanf(%d-%d-%d,&a,&b,&c);if((a%400==0)||(a%100!=0&&a%4==0))e=29;elsee=28;switch(b){case1:n=c;break;case2:n=g+c;break;case3:n=g+e+c;break;case4:n=g+e+g+c;break;case5:n=g+e+g+f+c;break;case6:n=g+e+g+f+g+c;break;case7:n=g+e+g+f+g+f+c;break;case8:n=g+e+g+f+g+f+g+c;break;case9:n=g+e+g+f+g+f+g+g+c;break;case10:n=g+e+g+f+g+f+g+g+f+c;break;case11:n=g+e+g+f+g+f+g+g+f+g+c;break;default:n=g+e+g+f+g+f+g+g+f+g+f+c;}printf(%d\n,n);return0;}9.#includestdio.hintmain(){intx;scanf(%d,&x);if(x=90&&x=100)printf(A\n);elseif(x=80)printf(B\n);elseif(x=70)printf(C\n);elseif(x=60)printf(D\n);elseprintf(E\n);return0;}10.#includestdio.hintmain(){doublex,y,s;scanf(%lf,%lf,&x,&y);s=(x+2)*(x+2)+(y-2)*(y-2);if(s1){s=(x+2)*(x+2)+(y+2)*(y+2);if(s1){s=(x-2)*(x-2)+(y+2)*(y+2);if(s1){s=(x-2)*(x-2)+(y-2)*(y-2);if(s1){printf(0\n);return1;}}}}printf(10\n);return0;}二。第二季15题全11.#includestdio.hintmain(){intx=0,a=0,c=0,i=1;scanf(%d%d,&x,&a);c=x;for(i=1;ia;i++){c=(c*x)%1000;};if(c100){if(c10)printf(00%d\n,c);elseprintf(0%d\n,c);};if(c=100)printf(%d\n,c);return0;}12.#includestdio.hintmain(){inti=1,a=0,b=0,c=1016,k=1;for(;k=1;){c=c+4;a=c;b=c;for(i=1;i=4;i++){a=a/4*5+1;if(a%4!=0){k=0;;};};a=a/4*5+1;if(k==1){printf(%d%d\n,a,b);break;};};return0;}13。。#includestdio.h#includemath.hintmain(){inti=1,n=0,b=0;doublej=0,k=0,m=0;scanf(%d,&n);for(;i=n;i++){b=i%2-1;k=pow(-1,b);m=pow(2,i);j+=k*m/(m-k)/(2*m+k);};printf(%.6lf\n,j);return0;}14.#includestdio.h#includemath.hintmain(){inta=0,b=0,i=0,t;scanf(%d%d,&a,&b);if(ab){t=a;a=b;b=t;}for(;a=b;a++){intm=1;for(i=2;i=sqrt(a);i++){if(a%i==0){m=0;break;};}if(m==1)printf(%d,a);}printf(\n);return0;}15.#includestdio.h#includemath.hintmain(){inta=0,b=0,c=0;scanf(%d,&a);b=(int)pow(a,2);c=(int)pow(a,3);if(a%2){printf(%d*%d*%d=%d=%d,a,a,a,c,b-a/2*2);intn=1;for(;na;n++){printf(+%d,b-a/2*2+2*n);}printf(\n);};if(a%2==0){intn=1;printf(%d*%d*%d=%d=%d,a,a,a,c,b+1-a);for(;na;n++){printf(+%d,b+1-a+n*2);}printf(\n);};return0;}16#includestdio.h#includemath.hintmain(){inta=0,b=0,c=0,d=0,e=0,x=0,y=0,z=0,u=0,v=0;doublef=0;for(a=0;a=2;a++){doublem=0;for(b=0;b=(20-8*a)/5;b++){for(c=0;c=(20-8*a-5*b)/3;c++){for(d=0;d=(20-8*a-5*b-3*c)/2;d++){e=20-8*a-5*b-3*c-2*d;m=2000*pow(1+0.0084*12*8,a)*pow(1+0.0075*12*5,b)*pow(1+0.0069*12*3,c)*pow(1+0.0066*12*2,d)*pow(1+0.0063*12,e);if(fm){f=m;x=a,y=b,z=c,u=d,v=e;};};};};};printf(%d%d%d%d%d\n%.2lf\n,x,y,z,u,v,f);return0;}17.#includestdio.h#includemath.hintmain(){doublea=0;inti=0,b=0;scanf(%lf,&a);b=(int)a;for(;(int)(b/pow(10,i));)i++;printf(%d\n,i);return0;}18。#includestdio.hintmain(){doublea=1,b=2,i=1,m=0;for(;i=20;i++){m+=b/a;b=a+b;a=b-a;}printf(%.6lf\n,m);return0;}19.#includestdio.h#includemath.hintmain(){doublea=0,b=0,c=0,e=0;scanf(%lf%lf,&a,&b);for(;b-a0.0001;){c=2*pow(a,3)-4*pow(a,2)+3*a-6;e=2*pow((a+b)/2,3)-4*pow((a+b)/2,2)+3*(a+b)/2-6;if(c*e==0){if(e==0)a=(a+b)/2;break;};if(c*e!=0){if(c*e0)b=(a+b)/2;elsea=(a+b)/2;};};printf(%.2lf\n,a);return0;}20.#includestdio.hintmain(){chari,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((k!='X')&&(k!='Z')&&(i!='X'))printf(A=%c\nB=%c\nC=%c\n,i,j,k);return0;}21.#includestdio.hintmain(){inta,b,i,j,cnt=0,sum=0;b=-1;for(i=500;i=800;i++){for(j=2;ji;j++){if(i%j==0)break;}if(ji-1){cnt++;a=b*i;sum+=a;b=-b;}}printf(%d%d\n,cnt,sum);return0;}22.#includestdio.hintmain(){inti=2,A1=1,A2=1,A3,A4,n,M=10,j,S1=2,S2=0;for(n=1;n=3;n++){M=M*10;for(j=1;S1+A4M||S2=M;j++){A3=A1+2*A2;A4=A2+2*A3;S1=S1+A3;S2=S1+A4;A1=A2;A2=A3;i++;}printf(%d\n,i);}return0;}23.#includestdio.h#includemath.hintmain(){doublex1,x2,x3=0,a;scanf(%lf,&a);x1=a;while(
本文标题:西工大C语言POJ习题答案
链接地址:https://www.777doc.com/doc-5324217 .html