西工大NOJ答案完全版(共113页).doc
精选优质文档-倾情为你奉上#include<stdio.h>int main() int a,b,sum; scanf("%d%d",&a,&b); sum=a+b; printf("%dn",sum); return 0;#include<stdio.h>#define PI 3.int main() double r,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); return 0;#include<stdio.h>int main() double ma,eng,c,sum,ave; scanf("%lf%lf%lf",&ma,&eng,&c); sum=ma+eng+c; ave=sum/3; printf("%lfn%lfn",sum,ave); return 0;#include<stdio.h>int main() int a,b,c,m; scanf("%d%d%d",&a,&b,&c); if (a>b) m=a; else m=b; if (m<c) m=c; printf("%d",m); return 0;#include<stdio.h>int main() int n; scanf("%d",&n); if (1000<n<10000)&&(n/1000=n%10)&&(n/100%10=n/10%10) printf("yesn"); else if(100<n<=1000)&&(n/100=n%10) printf("yesn"); else if(10<n<=100)&&(n/10=n%10) printf("yesn"); else if(0<n<=10) printf("yesn"); else printf("non"); return 0;#include<stdio.h>int main() double l,bon; scanf("%lf",&l); if(l<=10) bon=l*0.1; else if(l<20) bon=1+(l-10)*0.075; else if(l<40) bon=1.75+(l-20)*0.05; else if(l<60) bon=2.75+(l-40)*0.03; else if(l<100) bon=3.35+(l-60)*0.015; else bon=3.95+(l-100)*0.01; printf("%lfn",bon); return 0;#include<stdio.h>int main() double d,m; scanf("%lf",&d); if(d<=2) m=7; else if(d<=15) if(d-2=(int)(d-2) m=7+(d-2)*1.5; else m=7+(int)(d-2)+1)*1.5; else if(d-15=(int)(d-15) m=26.5+(d-15)*2.1; else m=26.5+(int)(d-15)+1)*2.1; printf("%lfn",m); return 0;#include<stdio.h>int main() int y,m,d,Days,sum; scanf("%d-%d-%d",&y,&m,&d); if(y%4=0&&y%100!=0)|(y%400=0) Days=29; else Days=28; switch(m) case 1:sum=d;break; case 2:sum=31+d;break; case 3:sum=31+Days+d;break; case 4:sum=62+Days+d;break; case 5:sum=92+Days+d;break; case 6:sum=123+Days+d;break; case 7:sum=153+Days+d;break; case 8:sum=184+Days+d;break; case 9:sum=215+Days+d;break; case 10:sum=245+Days+d;break; case 11:sum=276+Days+d;break; case 12:sum=307+Days+d;break; printf("%dn",sum); return 0;#include<stdio.h>int main() int i; scanf("%d",&i); if(i>=90) printf("An"); else if(i>=80) printf("Bn"); else if(i>=70) printf("Cn"); else if(i>=60) printf("Dn"); else printf("En"); return 0;#include<stdio.h>int main() double x,y; scanf("%lf,%lf",&x,&y); if(x-2)*(x-2)+(y-2)*(y-2)<=1) printf("10"); else if(x-2)*(x-2)+(y+2)*(y+2)<=1) printf("10"); else if(x+2)*(x+2)+(y-2)*(y-2)<=1) printf("10"); else if(x+2)*(x+2)+(y+2)*(y+2)<=1) printf("10"); else printf("0"); return 0;#include<stdio.h>int main() double l,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; else l=x; if(2*l*l*l-4*l*l+3*l-6=0) printf("%.2lf",l); else printf("%.2lf",r); return 0;#include<stdio.h>#include<math.h>int main() int i=800,t=2,cnt=0,sum=0; double e=-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); return 0;#include<stdio.h>#include<math.h>int main() int a=1; double b=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); return 0;#include<stdio.h>int main() int a1=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>int main() int x,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); return 0;#include<stdio.h>int main() int m,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); else for(s=-n/2;s<n/2-1;s+)printf("%d+",m+s*2+1); printf("%d",m+(n/2-1)*2+1); return 0;#include<stdio.h>int main() char a,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); return 0;#include<stdio.h>int main() int a,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); return 0;#include<stdio.h>int main() int n=1; double a1=1,a2=2,a3,sum=2; while(n<=19) a3=a1+a2; sum=sum+a3/a2; a1=a2; a2=a3; n+; printf("%lfn",sum); return 0;#include<stdio.h>#include<math.h>int main() double a; int n=0; scanf("%lf",&a); a=fabs(a); if(a<=1)printf("0n"); else while(a>1) a=a/10; n+; printf("%dn",n); return 0;#include<stdio.h>int main() int a=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); return 0;#include<stdio.h>#include<math.h>int main() int n; int f(int n); scanf("%d",&n); printf("%dn",f(n);int f(int n) int a; if(n=1|n=2) a=0; else if(n=3) a=1; else if(n=4) a=3; else a=f(n-1)*2+pow(2,n-4)-f(n-4); return a;#include<stdio.h>int main() int n,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); return 0;#include<stdio.h>#include<stdlib.h>#include<math.h>int main() int m,n,i; double x,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); return 0;#include<stdio.h>int main() int x,y,a,b,L; double t; scanf("%d%d%d%d%d",&x,&y,&a,&b,&L); if(a=b) printf("impossiblen"); else if(x>y) if(a>b)y=L-x+y,t=(double)y/(a-b); else y=x-y,t=(double)y/(b-a); if(int)t=t)printf("%dn",(int)t); else printf("%lfn",t); else if(a>b)y=y-x,t=(double)y/(a-b); else y=L-y+x,t=(double)y/(b-a); if(int)t=t)printf("%dn",(int)t); else printf("%lfn",t); return 0;#include<stdio.h>int _max(int a,int b) return a>b?a:b;int a20;int f2020;int main() int n,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"); else printf("%dn",s); return 0;#include<stdio.h>int main() int x=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); return 0;#include<stdio.h>int main() int a,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"); return 0;#include<stdio.h>#include<math.h>int main() int ce,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); return 0;#include<stdio.h>int main() int n,i; scanf("%d",&n); for(i=1;i<=n;i+) if(i%7=0) printf("%d ",i); else if(i/1000%10=7|i/100%10=7|i/10%10=7|i%10=7) printf("%d ",i); return 0;#include<stdio.h>double a;int main() int n,i; double ave,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); return 0;#include<stdio.h>int f;int main() int n,i; scanf("%d",&n); for(i=0;i<n;i+) int a,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); else printf("%dn",fi); return 0;#include<stdio.h>#include<math.h>int getbit(int n,int k) n=n>>k-1; return n&1;int main() int n,k; scanf("%d%d",&n,&k); printf("%d",getbit(n,k); return 0;#include<stdio.h>int _min(int n) int i=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; return i;int f100;int main() int n,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); return 0;#include<stdio.h>int fceil(double x) if(x>0) if(int)x=x) return x; else return (int)x+1; else return (int)x;int main() double x; scanf("%lf",&x); printf("%dn",fceil(x); return 0;#include<stdio.h>int _move(int value,int n) int t; if(n>0) t=value>>n|value<<32-n; else n=-n; t=value<<n|value>>32-n; return t;int main() int value,n; scanf("%d%d",&value,&n); printf("%dn",_move(value,n); return 0;#include<stdio.h>void timesum(int AH,int AM,int AS,int BH,int BM,int BS) int h=0,m=0,s=0; if(AS+BS>59) s=(AS+BS)-60,m+; else s=AS+BS; if(AM+BM>59) m+=(AM+BM)-60),h+; else m=AM+BM; h+=(AH+BH); printf("%d %d %dn",h,m,s);int main() int AH,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); return 0;#include<stdio.h>void f(long int n) int m; m=n%10; printf("%d",m); n/=10; if(n!=0) f(n);int main() long int n; scanf("%d",&n); f(n); return 0;#include<stdio.h>int getfloor(double x) if(x>0) return (int)x; else return (int)x-1;int main() double x; scanf("%lf",&x); printf("%dn",getfloor(x); return 0;#include<stdio.h>inline int xchg(unsigned char n) n=n>>4|n<<4; return n;int main() unsigned char n; scanf("%d",&n); printf("%dn",xchg(n); return 0;#include<stdio.h>void QuickSort(int A100,int s,int m) int i,t; for(;s<=m;s+) for(i=s;i<=m;i+) if(As<Ai) t=As; As=Ai; Ai=t; printf("%d ",As); int main() int s,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); return 0;#include<stdio.h>double avg(int A100,int s,int e) double sum; for(sum=0;s<=e;s+) sum=sum+As; return sum;int main() int A100,s,e,i,n; double a; 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); return 0;#include<stdio.h>int main() int n,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+; else if(ai<aj) t+; s=s>t?t:s; printf("%dn",s); return 0;#include<stdio.h>void SelectionSort(int A,int s,int m) int i,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); int main() int s,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); return 0;#include<stdio.h>void SelectionSort(int A,int s,int m) int i,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); int main() int s,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); return 0;#include<stdio.h>int main() int a100100,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(" "); else printf("%d ",aij); if(j=n-1) printf("n"); return 0;#include<stdio.h>int main() int a100100,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<i) printf(" "); else printf("%d ",aij); if(j=n-1) printf("n"); return 0;#include<stdio.h>int main() int a100100,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(" "); else printf("%d ",aij); if(j=n-1) printf("n"); return 0;#include<stdio.h>int main() int a100100,n,m,i,j,s1,s2; scanf("%d%d",&n,&m); for(i=0;i<n;i+) for(j=0;j<m;j+) scanf("%d",&aij); for(j=0,s1=0;j<m;j+) s1=s1+a0j+an-1j; for(i=1,s2=0;i<n-1;