西工大NOJ内容标准答案完全版.doc
,.#include<stdio.h>intmain()inta,b,sum;scanf("%d%d",&a,&b);sum=a+b;printf("%dn",sum);return0;#include<stdio.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=PI*r*r*r*4/3;vz=PI*r*r*h;printf("%.2lfn%.2lfn%.2lfn%.2lfn%.2lfn",l,s,sq,vq,vz);return0;#include<stdio.h>intmain()doublema,eng,c,sum,ave;scanf("%lf%lf%lf",&ma,&eng,&c);sum=ma+eng+c;ave=sum/3;printf("%lfn%lfn",sum,ave);return0;#include<stdio.h>intmain()inta,b,c,m;scanf("%d%d%d",&a,&b,&c);if(a>b)m=a;elsem=b;if(m<c)m=c;printf("%d",m);return0;#include<stdio.h>intmain()intn;scanf("%d",&n);if(1000<n<10000)&&(n/1000=n%10)&&(n/100%10=n/10%10)printf("yesn");elseif(100<n<=1000)&&(n/100=n%10)printf("yesn");elseif(10<n<=100)&&(n/10=n%10)printf("yesn");elseif(0<n<=10)printf("yesn");elseprintf("non");return0;#include<stdio.h>intmain()doublel,bon;scanf("%lf",&l);if(l<=10)bon=l*0.1;elseif(l<20)bon=1+(l-10)*0.075;elseif(l<40)bon=1.75+(l-20)*0.05;elseif(l<60)bon=2.75+(l-40)*0.03;elseif(l<100)bon=3.35+(l-60)*0.015;elsebon=3.95+(l-100)*0.01;printf("%lfn",bon);return0;#include<stdio.h>intmain()doubled,m;scanf("%lf",&d);if(d<=2)m=7;elseif(d<=15)if(d-2=(int)(d-2)m=7+(d-2)*1.5;elsem=7+(int)(d-2)+1)*1.5;elseif(d-15=(int)(d-15)m=26.5+(d-15)*2.1;elsem=26.5+(int)(d-15)+1)*2.1;printf("%lfn",m);return0;#include<stdio.h>intmain()inty,m,d,Days,sum;scanf("%d-%d-%d",&y,&m,&d);if(y%4=0&&y%100!=0)|(y%400=0)Days=29;elseDays=28;switch(m)case1:sum=d;break;case2:sum=31+d;break;case3:sum=31+Days+d;break;case4:sum=62+Days+d;break;case5:sum=92+Days+d;break;case6:sum=123+Days+d;break;case7:sum=153+Days+d;break;case8:sum=184+Days+d;break;case9:sum=215+Days+d;break;case10:sum=245+Days+d;break;case11:sum=276+Days+d;break;case12:sum=307+Days+d;break;printf("%dn",sum);return0;#include<stdio.h>intmain()inti;scanf("%d",&i);if(i>=90)printf("An");elseif(i>=80)printf("Bn");elseif(i>=70)printf("Cn");elseif(i>=60)printf("Dn");elseprintf("En");return0;#include<stdio.h>intmain()doublex,y;scanf("%lf,%lf",&x,&y);if(x-2)*(x-2)+(y-2)*(y-2)<=1)printf("10");elseif(x-2)*(x-2)+(y+2)*(y+2)<=1)printf("10");elseif(x+2)*(x+2)+(y-2)*(y-2)<=1)printf("10");elseif(x+2)*(x+2)+(y+2)*(y+2)<=1)printf("10");elseprintf("0");return0;#include<stdio.h>intmain()doublel,x,r;scanf("%lf%lf",&l,&r);while(2*l*l*l-4*l*l+3*l-6)!=0&&(2*r*r*r-4*r*r+3*r-6)!=0)x=(l+r)/2;if(2*l*l*l-4*l*l+3*l-6)*(2*x*x*x-4*x*x+3*x-6)<=0)r=x;elsel=x;if(2*l*l*l-4*l*l+3*l-6=0)printf("%.2lf",l);elseprintf("%.2lf",r);return0;#include<stdio.h>#include<math.h>intmain()inti=800,t=2,cnt=0,sum=0;doublee=-1;while(i>=500)while(t<=i-1)if(i%t=0)break;t+;if(t=i)e=pow(-1,cnt),sum=sum+e*i,cnt+;i-;t=2;printf("%d%d",cnt,sum);return0;#include<stdio.h>#include<math.h>intmain()inta=1;doubleb=1,pi=0,c=1;while(fabs(c)>=1e-6)pi=pi+c,b=b+2,a=-a,c=a/b;pi=pi*4;printf("%lfn",pi);return0;#include<stdio.h>intmain()inta1=1,a2=1,n=2,sum=2,t;while(sum<=100)t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n+;printf("%dn",n-1);while(sum<=1000)t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n+;printf("%dn",n-1);while(sum<=10000)t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n+;printf("%dn",n-1);#include<stdio.h>intmain()intx,a,s,n=1;scanf("%d%d",&x,&a);s=x;if(a!=0)for(;n<a;n+)s=s*x;if(s>=1000)s=s/100%10*100+s/10%10*10+s%10;printf("%dn",s);return0;#include<stdio.h>intmain()intm,n,s;scanf("%d",&n);s=n*n*n;printf("%d*%d*%d=%d=",n,n,n,s);for(m=1;s!=n*m;m+);if(n%2=1)for(s=-n/2;s<n/2;s+)printf("%d+",m+2*s);printf("%d",m+n/2*2);elsefor(s=-n/2;s<n/2-1;s+)printf("%d+",m+s*2+1);printf("%d",m+(n/2-1)*2+1);return0;#include<stdio.h>intmain()chara,b,c,x,y,z;a=A,b=B,c=C,x=X,y=Y,z=Z;printf("%c=%cn",a,z);printf("%c=%cn",b,x);printf("%c=%cn",c,y);return0;#include<stdio.h>intmain()inta,b,t;scanf("%d%d",&a,&b);if(a>b)t=a,a=b,b=t;for(;a<b;a+)for(t=2;t<a;t+)if(a%t=0)break;if(t=a)printf("%d",a);return0;#include<stdio.h>intmain()intn=1;doublea1=1,a2=2,a3,sum=2;while(n<=19)a3=a1+a2;sum=sum+a3/a2;a1=a2;a2=a3;n+;printf("%lfn",sum);return0;#include<stdio.h>#include<math.h>intmain()doublea;intn=0;scanf("%lf",&a);a=fabs(a);if(a<=1)printf("0n");elsewhile(a>1)a=a/10;n+;printf("%dn",n);return0;#include<stdio.h>intmain()inta=1,b=0,t,m,n=0;scanf("%d",&t);while(n<t)m=b;b=3*a+2*b;a=m;n+;printf("%d%d",a,b);return0;#include<stdio.h>#include<math.h>intmain()intn;intf(intn);scanf("%d",&n);printf("%dn",f(n);intf(intn)inta;if(n=1|n=2)a=0;elseif(n=3)a=1;elseif(n=4)a=3;elsea=f(n-1)*2+pow(2,n-4)-f(n-4);returna;#include<stdio.h>intmain()intn,x=1234,y=1,a,b,c,d,e,f,g,h,i,j;scanf("%d",&n);for(;x<49383&&y<98765;x+)y=x*n;a=x/10000%10;b=x/1000%10;c=x/100%10;d=x/10%10;e=x%10;f=y/10000%10;g=y/1000%10;h=y/100%10;i=y/10%10;j=y%10;if(a=b|a=c|a=d|a=e|a=f|a=g|a=h|a=i|a=j)continue;if(b=c|b=d|b=e|b=f|b=g|b=h|b=i|b=j)continue;if(c=d|c=e|c=f|c=g|c=h|c=i|c=j)continue;if(d=e|d=f|d=g|d=h|d=i|d=j)continue;if(e=f|e=g|e=h|e=i|e=j)continue;if(f=g|f=h|f=i|f=j)continue;if(g=h|g=i|g=j)continue;if(h=i|h=j)continue;if(i=j)continue;printf("%05d/%05d=%dn",y,x,n);return0;#include<stdio.h>#include<stdlib.h>#include<math.h>intmain()intm,n,i;doublex,s=0;scanf("%d%d",&n,&m);for(i=n;i<=m;i+)x=pow(i,2.0);s=s+1/x;printf("%.5lfn",s);return0;#include<stdio.h>intmain()intx,y,a,b,L;doublet;scanf("%d%d%d%d%d",&x,&y,&a,&b,&L);if(a=b)printf("impossiblen");elseif(x>y)if(a>b)y=L-x+y,t=(double)y/(a-b);elsey=x-y,t=(double)y/(b-a);if(int)t=t)printf("%dn",(int)t);elseprintf("%lfn",t);elseif(a>b)y=y-x,t=(double)y/(a-b);elsey=L-y+x,t=(double)y/(b-a);if(int)t=t)printf("%dn",(int)t);elseprintf("%lfn",t);return0;#include<stdio.h>int_max(inta,intb)returna>b?a:b;inta20;intf2020;intmain()intn,i,j,s=0;scanf("%d",&n);for(i=0;i<n;i+)scanf("%d",&ai);for(j=1;j<n;j+)f00=a0,f0j=f0j-1*aj;for(i=1;i<n;i+)fii-1=1;for(j=i;j<n;j+)fij=fij-1*aj;for(i=0;i<n;i+)for(j=i;j<n;j+)s=_max(s,fij);if(s=0)printf("-1n");elseprintf("%dn",s);return0;#include<stdio.h>intmain()intx=192,y,z,a,b,c,d,e,f,g,h,i;for(;x<328;x+)y=2*x;z=3*x;a=x/100%10;b=x/10%10;c=x%10;d=y/100%10;e=y/10%10;f=y%10;g=z/100%10;h=z/10%10;i=z%10;if(a=b|a=c|a=d|a=e|a=f|a=g|a=h|a=i|a=0)continue;if(b=c|b=d|b=e|b=f|b=g|b=h|b=i|b=0)continue;if(c=d|c=e|c=f|c=g|c=h|c=i|c=0)continue;if(d=e|d=f|d=g|d=h|d=i|d=0)continue;if(e=f|e=g|e=h|e=i|e=0)continue;if(f=g|f=h|f=i|f=0)continue;if(g=h|g=i|g=0)continue;if(h=i|h=0)continue;printf("%d%d%dn",x,y,z);return0;#include<stdio.h>intmain()inta,b,c,sum=10;scanf("%d%d%d",&a,&b,&c);for(;sum<=100;sum+)if(sum%3=a&&sum%5=b&&sum%7=c)printf("%dn",sum);break;if(sum=101)printf("-1n");return0;#include<stdio.h>#include<math.h>intmain()intce,y,m,n,a=0;scanf("%d",&n);for(ce=0;ce+=100)for(y=ce+1;y<ce+100;y+=2)for(m=3;m<sqrt(y);m+=2)if(y%m=0)break;if(m>=sqrt(y)break;if(y=ce+101)a+;if(a=n)break;printf("%d%dn",ce,ce+99);return0;#include<stdio.h>intmain()intn,i;scanf("%d",&n);for(i=1;i<=n;i+)if(i%7=0)printf("%d",i);elseif(i/1000%10=7|i/100%10=7|i/10%10=7|i%10=7)printf("%d",i);return0;#include<stdio.h>doublea100000000;intmain()intn,i;doubleave,sum=0;scanf("%d",&n);for(i=0;i<n;i+)scanf("%lf",&ai);sum=sum+ai;ave=sum/n;for(i=0,sum=0;i<n;i+)sum=sum+(ai-ave)*(ai-ave);printf("%lfn",sum);return0;#include<stdio.h>intf100000000;intmain()intn,i;scanf("%d",&n);for(i=0;i<n;i+)inta,b;scanf("%d%d",&a,&b);fi=a+b;for(i=0;i<n;i+)if(fi>100)fi=fi/10%10*10+fi%10,printf("%dn",fi);elseprintf("%dn",fi);return0;#include<stdio.h>#include<math.h>intgetbit(intn,intk)n=n>>k-1;returnn&1;intmain()intn,k;scanf("%d%d",&n,&k);printf("%d",getbit(n,k);return0;#include<stdio.h>int_min(intn)inti=0;if(n>=100)i=n/100%10,n=n/10%10*10+n%10;if(n>=50)i+=1,n-=50;if(n>=10)i+=n/10%10,n%=10;if(n>=5)i+=1,n-=5;if(n>=2)i+=n/2,n%=2;if(n=1)i+=1;returni;intf100;intmain()intn,i,sum;scanf("%d",&n);for(i=0;i<n;i+)scanf("%d",&fi);for(sum=0,i=0;i<n;i+)sum=sum+_min(fi);printf("%dn",sum);return0;#include<stdio.h>intfceil(doublex)if(x>0)if(int)x=x)returnx;elsereturn(int)x+1;elsereturn(int)x;intmain()doublex;scanf("%lf",&x);printf("%dn",fceil(x);return0;#include<stdio.h>int_move(intvalue,intn)intt;if(n>0)t=value>>n|value<<32-n;elsen=-n;t=value<<n|value>>32-n;returnt;intmain()intvalue,n;scanf("%d%d",&value,&n);printf("%dn",_move(value,n);return0;#include<stdio.h>voidtimesum(intAH,intAM,intAS,intBH,intBM,intBS)inth=0,m=0,s=0;if(AS+BS>59)s=(AS+BS)-60,m+;elses=AS+BS;if(AM+BM>59)m+=(AM+BM)-60),h+;elsem=AM+BM;h+=(AH+BH);printf("%d%d%dn",h,m,s);intmain()intAH,AM,AS,BH,BM,BS;scanf("%d%d%d%d%d%d",&AH,&AM,&AS,&BH,&BM,&BS);timesum(AH,AM,AS,BH,BM,BS);return0;#include<stdio.h>voidf(longintn)intm;m=n%10;printf("%d",m);n/=10;if(n!=0)f(n);intmain()longintn;scanf("%d",&n);f(n);return0;#include<stdio.h>intgetfloor(doublex)if(x>0)return(int)x;elsereturn(int)x-1;intmain()doublex;scanf("%lf",&x);printf("%dn",getfloor(x);return0;#include<stdio.h>inlineintxchg(unsignedcharn)n=n>>4|n<<4;returnn;intmain()unsignedcharn;scanf("%d",&n);printf("%dn",xchg(n);return0;#include<stdio.h>voidQuickSort(intA100,ints,intm)inti,t;for(;s<=m;s+)for(i=s;i<=m;i+)if(As<Ai)t=As;As=Ai;Ai=t;printf("%d",As);intmain()ints,m,n,i,A100;scanf("%d",&n);for(i=0;i<n;i+)scanf("%d",&Ai);scanf("%d%d",&s,&m);for(i=0;i<s;i+)printf("%d",Ai);QuickSort(A,s,m);for(i=m+1;i<n;i+)printf("%d",Ai);return0;#include<stdio.h>doubleavg(intA100,ints,inte)doublesum;for(sum=0;s<=e;s+)sum=sum+As;returnsum;intmain()intA100,s,e,i,n;doublea;scanf("%d",&n);for(i=0;i<n;i+)scanf("%d",&Ai);scanf("%d%d",&s,&e);a=avg(A,s,e)/(e-s+1);printf("%lfn",a);return0;#include<stdio.h>intmain()intn,a100,i,j,s=0,t=0;scanf("%d",&n);for(i=0;i<n;i+)scanf("%d",&ai);for(i=0;i<n-1;i+)for(j=i+1;j<n;j+)if(ai>aj)s+;elseif(ai<aj)t+;s=s>t?t:s;printf("%dn",s);return0;#include<stdio.h>voidSelectionSort(intA,ints,intm)inti,t,n;for(n=s;n<=s+m-1;n+)for(i=n;i<=s+m-1;i+)if(An<Ai)t=An;An=Ai;Ai=t;printf("%d",An);intmain()ints,m,n,i,A100;scanf("%d",&n);for(i=0;i<n;i+)scanf("%d",&Ai);scanf("%d%d",&s,&m);for(i=0;i<s;i+)printf("%d",Ai);SelectionSort(A,s,m);for(i=m+1;i<n;i+)printf("%d",Ai);return0;#include<stdio.h>voidSelectionSort(intA,ints,intm)inti,t,n;for(n=s;n<=s+m-1;n+)for(i=n;i<=s+m-1;i+)if(An<Ai)t=An;An=Ai;Ai=t;printf("%d",An);intmain()ints,m,n,i,A100;scanf("%d",&n);for(i=0;i<n;i+)scanf("%d",&Ai);scanf("%d%d",&s,&m);for(i=0;i<s;i+)printf("%d",Ai);SelectionSort(A,s,m);for(i=m+1;i<n;i+)printf("%d",Ai);return0;#include<stdio.h>intmain()inta100100,n,i,j;scanf("%d",&n);for(i=0;i<n;i+)for(j=0;j<n;j+)scanf("%d",&aij);for(i=0;i<n;i+)for(j=0;j<n;j+)if(j<n-i-1)printf("");elseprintf("%d",aij);if(j=n-1)printf("n");return0;#include<stdio.h>intmain()inta1