UJN_ACM_Zgq

From UJN_ACM_Zgq

ACM系统网址:acm.ujn.edu.cn

题目信息列表:http://acm.ujn.edu.cn/JudgeOnline/problemset.php

PS:UJN的学生可以参考,其他学校的同学可以在题目信息提交,不过学校暂未开放外校学生注册功能

想借账号的联系邮箱:3312164767@qq.com

Problem1000:#include using namespace std; int main() { int m, n; cin >> m >> n; cout << m + n << endl; }
Problem1001:#include int main() { int a,b,c; scanf("%d%d",&a,&b); c=a+b; printf("%d",c); return 0; }
Problem1002:#include int main() { printf("Hello, World!"); }
Problem1003:#include //#include //#define M 6*pow(10,24) //#define R 6.371*pow(10,6) int main() { int x,y,mid; scanf("%d%d",&x,&y); mid=x; x=y; y=mid; printf("%d %d",x,y); return 0; } 
Problem1004:#include #define PI 3.14 int main() { double r,a,b,c,d; scanf("%lf",&r); a=PI*2*r; b=PI*r*r; /*c=PI*4*r*r; d=4.0/3*PI*r*r*r;*/ printf("%.2lf %.2lf",a,b); return 0; } 
Problem1005:#include int main() { printf("*\n**\n***\n****\n"); }
Problem1006:#include int main() { float C,F; scanf("%f",&F); C=5*(F32)/9; printf("%.2f",C); return 0; }
Problem1007:#include #include int main() { double a,b,c,s,area; scanf("%lf%lf%lf",&a,&b,&c); if(a+b>c&&b+c>a&&a+c>b) { s=(a+b+c)/2; area=sqrt(s*(sa)*(sb)*(sc)); printf("%.2lf",area); } else printf("No"); return 0; }
Problem1008:#include #define PI 3.1415926 int main() { double r,a,b,c,d; scanf("%lf",&r); a=PI*2*r; b=PI*r*r; c=PI*4*r*r; d=4.0/3*PI*r*r*r; printf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n",a,b,c,d); return 0; } 
Problem1009:#include int main() { int x,y,z; scanf("%d",&x); y=x/7; z=x%7; printf("%d %d",y,z); return 0; }
Problem1010:#include int main() { int a,b,c,d; scanf("%d",&a); b=a/3600%24; c=a/60%60; d=a%60; printf("%02d %02d:%02d:%02d",a/24/3600,b,c,d); return 0; } 
Problem1011:#include int main() { char x,y; scanf("%c",&x); y=x+32; printf("%c",y); return 0; }
Problem1011:#include int main() { char a; scanf("%c",&a); a=a+32; printf("%c",a); return 0; } 
Problem1012:#include int main() { double x,a,b,c; scanf("%lf%lf%lf",&a,&b,&c); x=a*b*c/(a*b+b*c+a*c); printf("%.2lf",x); return 0; } 
Problem1014:#include #include int main() { printf("%f",cos(3.56)+log10(35)+exp(2.63)+log(8.56)+tan(0.78)); return 0; } 
Problem1015:#include //#include int main() { int a,b; scanf("%d%d",&a,&b); printf("%d %d %d %d",a+b,ab,a*b,a/b); return 0; } 
Problem1016:#include int main() { int x; scanf("%d",&x); if(x%100==0) printf("%d 0 0",x); else if(x%10==0) printf("%d %d 0",x/100,x/10); else printf("%d %d %d",x/100,x%100/10,x%10); return 0; }
Problem1016:#include //#include int main() { int a,b,c; scanf("%d",&a); b=a%100/10; c=a%100%10; printf("%d %d %d",a/100,b,c); return 0; } 
Problem1017:#include //#include int main() { int a,b,c; float d; scanf("%d%d",&a,&b); c=a%b; d=(float)a/b; printf("%d %d %.2f",a/b,c,d); return 0; } 
Problem1018:#include #include #define M 6*pow(10,24) #define R 6.371*pow(10,6) int main() { double a,b; double PI; scanf("%lf",&a); PI=4.0*atan(1.0); b=pow(6.67*pow(10,11)*M*a*a/4/PI/PI,1/3.0)R; printf("%.0lf",b); return 0; } 
Problem1019:#include int main() { int x,y; scanf("%d",&x); y=x%2; if(y==1) printf("odd"); else printf("even"); return 0; }
Problem1020:#include #include int main() { double x,y; scanf("%lf",&x); if(x<1) { y=pow(x,3)1; printf("%.2lf",y);} else if(x>=1&&x<=1) { y=3*x+1; printf("%.2lf",y);} else if(x>1&&x<=10) { y=3*exp(2*x1)+5; printf("%.2lf",y);} else { y=5*x+3*log10(2*pow(x,2)1)13; printf("%.2lf",y);} return 0; }
Problem1021:#include int main() { char x; scanf("%c",&x); if(x>='A'&&x<='Z'||x>='a'&&x<='z') printf("alpha"); else if(x>='0'&&x<='9') printf("numeric"); else printf("other"); return 0; }
Problem1022:#include int main() { double x,y,z; scanf("%lf%lf%lf",&x,&y,&z); if(x+y>z&&x+z>y&&z+y>x) {if(x==y&&y==z) printf("equilateral triangle"); else if(x==y||y==z||x==z) printf("isosceles triangle"); else printf("common triangle");} else printf("not a triangle"); return 0; }
Problem1023:#include int main() { int x; scanf("%d",&x); if(x%4==0&&x%100!=0||x%400==0) printf("Yes"); else printf("No"); return 0; }
Problem1024:#include int main() { int x; scanf("%d",&x); if(x==1) printf("Good morning"); else if(x==2) printf("Good afternoon"); else if(x==3) printf("Good evening"); else if(x==4) printf("Good night"); else printf("Bye bye"); return 0; }
Problem1024:#include int main() { int x; scanf("%d",&x); switch(x) {case 1:printf("Good morning");break; case 2:printf("Good afternoon");break; case 3:printf("Good evening");break; case 4:printf("Good night");break; default:printf("Bye bye"); } return 0; }
Problem1025:#include int main() { int x; scanf("%d",&x); switch(x/10) {case 10: case 9:printf("A");break; case 8:printf("B");break; case 7:printf("C");break; case 6:printf("D");break; default:printf("E"); } return 0; }
Problem1026:#include #include int main() { double x; int y; scanf("%lf%d",&x,&y); switch((y1)/12) {case 0:printf("%.2lf",x*pow(1.009,y));break; case 1:printf("%.2lf",x*pow(1.01,y));break; case 2:printf("%.2lf",x*pow(1.0111,y));break; default:printf("%.2lf",x*pow(1.012,y)); } return 0; }
Problem1027:#include int main() { int x; scanf("%d",&x); if(x%3==0&&x%5==0&&x%7==0) printf("Yes"); else printf("No"); return 0; }
Problem1028:#include int main() { int x,y,z,max,min; scanf("%d%d%d",&x,&y,&z); max=x>y?x:y; max=max>z?max:z; min=x int main() { int x,y,a,b,c,d; char z; scanf("%d%d %c",&x,&y,&z); if(z=='+') { a=x+y; printf("%d",a);} else if(z=='') { b=xy; printf("%d",b);} else if(z=='*') { c=x*y; printf("%d",c);} else { d=x/y; printf("%d",d);} return 0; }
Problem1029:#include int main() { int x,y; char a; scanf("%d%d %c",&x,&y,&a); switch(a) {case '+':printf("%d",x+y);break; case '':printf("%d",xy);break; case '*':printf("%d",x*y);break; case '/':printf("%d",x/y);break; } return 0; }
Problem1030:#include #include int main() { int x,y,z,max,min,middle; scanf("%d%d%d",&x,&y,&z); max=x>y?x:y; max=max>z?max:z; min=x #include //#define M 6*pow(10,24) //#define R 6.371*pow(10,6) int main() { double a,b,c,x,y,z; scanf("%lf%lf%lf",&a,&b,&c); z=b*b4*a*c; if(a==0) printf("No"); else if(z>=0.000001) { x=(b+sqrt(z))/2/a; y=(bsqrt(z))/2/a; if(x>y) printf("%.2lf %.2lf",y,x); else printf("%.2lf %.2lf",x,y); } else { x=(b)/(2*a); y=(sqrt(z))/2/a; printf("%.2lf%.2lfi %.2lf+%.2lfi",x,y,x,y);} return 0; } 
Problem1032:#include int main() { char x; scanf("%c",&x); if(x>='A'&&x<='Z') printf("%c",x+32); else if(x>='a'&&x<='z') printf("%c",x32); else printf("%c",x); return 0; }
Problem1033:#include #include //#define M 6*pow(10,24) //#define R 6.371*pow(10,6) int main() { double a,b,c,d,x; scanf("%lf%lf%lf%lf",&a,&b,&c,&d); x=sqrt(pow((ac),2)+pow((bd),2)); printf("%.2lf",x); return 0; } 
Problem1034:#include //#include //#define M 6*pow(10,24) //#define R 6.371*pow(10,6) int main() { int x; float a,b; scanf("%d",&x); if(x<3) {a=x*95; printf("%.2f",a);} else {b=x*95*0.85; printf("%.2f",b);} return 0; } 
Problem1035:#include //#include int main() { int a,n,i,j,k,count,mid; count=0;k=10000; scanf("%d",&n); a=mid=n; while(n>0){ n=n/10; count+=1; } printf("%d\n",count); while(a>0){ j=a/k; if(j!=0) if(a<10) printf("%d",j); else printf("%d ",j); a%=k; k/=10; } printf("\n"); do{ i=mid%10; if(mid<10) printf("%d",i); else printf("%d ",i); mid=mid/10; }while(mid%10!=0); return 0; } 
Problem1036:#include int main() { int i,n,sum; scanf("%d",&n); i=1; sum=0; while(i<=n) { sum=sum+i; i++; } printf("%d",sum); return 0; }
Problem1037:#include int main() { int i,n,sum; scanf("%d",&n); i=1; sum=0; while(i<=n) { sum=sum+i; i=i+2; } printf("%d",sum); return 0; }
Problem1038:#include int main() { int m,n,i,max,sum; while(scanf("%d%d",&m,&n)!=EOF){ if(m>n) {i=n; max=m;} else {i=m; max=n;} sum=0; for(;i<=max;i++) {if(i%3==0&&i%5==0) sum=sum+i;} printf("%d\n",sum); } return 0; } 
Problem1038:#include int main() { int m,n,mid,i,sum; while(scanf("%d%d",&m,&n)!=EOF) { if(m>n){mid=m;m=n;n=mid;} sum=0; for(i=m;i<=n;i++){ if(i%3==0&&i%5==0){ sum=sum+i; }} printf("%d\n",sum); } return 0; }
Problem1038:#include int main() {int a,b,c,i,j,k,sum; while(scanf("%d%d",&a,&b)!=EOF) {if(a>b) {j=a;k=b;} if(b>=a) {j=b;k=a;} sum=0; for(i=k;i<=j;i++) { while(i%3==0&&i%5==0) {sum=sum+i; i++;} } printf("%d\n",sum);} return 0; } 
Problem1038:#include int main() { int y,x,t,i,m,n,a,b,c=0; while(scanf("%d%d",&m,&n)!=EOF) { c=0; if(m>=n) { x=m; y=n; } else { x=n; y=m; } for(i=y;i<=x;i++) { a=i%3; b=i%5; if(a==0&&b==0) c=c+i; } printf("%d\n",c); } return 0; } 
Problem1038:#include int main() { int m,n,x,y,sum; while(scanf("%d%d",&m,&n)!=EOF) { if(m>n) {y=m;m=n;n=y;} sum=0; for(x=m;x<=n;x++) { if(x%3==0&&x%5==0) sum=sum+x; } printf("%d\n",sum); } return 0; } 
Problem1039:#include int main() { int n,m; scanf("%d%d",&n,&m); while(n<=m) { if(n%3==0&&n%5!=0) printf("%d ",n); n++; } return 0; }
Problem1040:#include //#include int main() { int m,n,i; scanf("%d%d",&n,&m); while(n<=m) { for(i=2;i #include int main() { int m,n,i,mid,j,k; scanf("%d%d",&m,&n); if(m>n){j=m;m=n;n=j;} for(;m<=n;m++){ mid=0; k=sqrt(m); for(i=2;i<=k+1;i++) { if(m%i==0){ mid++; } } if(mid==0){printf("%d ",m);} } return 0; }
Problem1040:#include #include int main() { int m,n,k,i,a; scanf("%d%d",&m,&n); for(k=m;k<=n;k++) { i=sqrt(k); for(a=2;a<=i+1;a++) if(k%a==0)break; if(a>i+1) printf("%d ",k); } return 0; } 
Problem1041:#include //#include int main() { int n,i,j; double a,sum; scanf("%lf%d",&a,&n); i=1;sum=0;j=a; do{ sum=sum+a; a=a*10+j; i++; }while(i<=n); printf("%.0lf",sum); return 0; } 
Problem1041:#include int main() { int i,j,n; double a,s; scanf("%lf%d",&a,&n); j=a;s=0;i=1; while(i<=n){ s=s+a; a=a*10+j; i++; } printf("%.0lf",s); return 0; }
Problem1042:#include int main() { int n,max; scanf("%d",&n); max=n; while(n!=0) { if(n>max) max=n; scanf("%d",&n); } printf("%d",max); return 0; }
Problem1043:#include int main() { int n,i; double sn,sum; scanf("%d",&n); sn=1;sum=0; for(i=1;i<=n;i++) { sn=sn*i; sum=sum+sn;} printf("%.0lf",sum); return 0; } 
Problem1043:#include int main() { int n,i,j; double s,sum; scanf("%d",&n); i=1;sum=0; while(i<=n) { for(j=1,s=1;j<=i;j++){ s=s*j; } sum=sum+s; i++; } printf("%.0lf",sum); return 0; }
Problem1043:#include int main() { double sum,n,i=1,j=1,a=1; scanf("%lf",&n); sum=0; for(i=1;i<=n;i++) { for(;j<=i;j++) a=a*j; sum=sum+a; } printf("%.0lf",sum); return 0; }
Problem1044:#include #include int main() { int n,i; double sum; scanf("%d",&n); i=1;sum=1; while(i<=n) {sum=sum*2; i++;} printf("%.lf",sum); return 0; } 
Problem1045:#include int main() { char n,i,j,k,m,s; scanf("%c",&n); i=j=k=m=s=0; while(n!='\n') { if(n>='0'&&n<='9') i++; else if(n>='a'&&n<='z') j++; else if(n>='A'&&n<='Z') k++; else if(n==' ') m++; else s++; scanf("%c",&n); } printf("%d %d %d %d %d",k,j,m,i,s); return 0; }
Problem1046:#include int main() { int n,i,j,k; scanf("%d",&n); i=j=k=0; while(n!=32767) { if(n>0) i++; else if(n==0) j++; else k++; scanf("%d",&n); } printf("%d %d %d",i,k,j); return 0; }
Problem1046:#include int main() { int i=0,j=0,k=0,m; scanf("%d",&m); while(m!=32767) { if(m>0) i++; else if(m<0) j++; else k++; scanf("%d",&m); } printf("%d %d %d",i,j,k); return 0; }
Problem1047:#include #include int main() { int n,i; double sum; scanf("%d",&n); i=1; while(i<=n) { sum=sum+i*i+i2.3; i++; } printf("%.1lf",sum); return 0; } 
Problem1047:#include #include #include int main() { double sum,i; int n; sum=0; scanf("%d",&n); for(i=1;i<=n;i++) sum=sum+pow(i,2)+i2.3; printf("%.1lf",sum); return 0; } 
Problem1048:#include int main() { int i,j=0; scanf("%d",&i); j=1; for(;i<=2100;i++) { if(i%12==2) if(i==2090) {printf("%d",i);} else printf("%d ",i); } return 0; } 
Problem1049:#include //#include int main() { int n,i,j,count; count=0; scanf("%d",&n); i=2; while(i<=n){ for(j=2;j int main() { int n,k; double i,j,sn,sum; scanf("%d",&n); i=1;sn=1;sum=0;j=0;k=0; while(k<=n) { sum=sum+i; i=1/(j+2); k+=2; j=j+2; } printf("%lf",sum); return 0; } 
Problem1050:#include int main() { int n; double sum,i; scanf("%d",&n); sum=1;i=2; while(i<=n){ sum=sum+1/i; i=i+2; } printf("%lf",sum); return 0; }
Problem1051:#include #include int main() { int x,y,z,s; x=0; while(x<20){ for(y=0;y<=33;y++) {z=100xy; s=15*x+9*y+z; if(s==300) printf("%d %d %d\n",x,y,z);} x++; } return 0; } 
Problem1051:#include int main() { int x,y,z; x=0; while(x<=20){ for(y=0;y<=33;y++){ for(z=0;z<=100;z++){ if(x+y+z==100&&15*x+9*y+z==300){ printf("%d %d %d\n",x,y,z); } } } x++; } return 0; } 
Problem1052:#include int main() { int i,n,sum; scanf("%d",&n); i=sum=1; while(i //#include int main() { int n,m,sum; sum=0; scanf("%d%d",&n,&m); while(n<=m) { if(n%3==0) sum=sum+n; n++; } printf("%d",sum); return 0; } 
Problem1053:#include int main() { int m,n,sum,mid,i; scanf("%d%d",&m,&n); if(n>m){mid=m;m=n;n=mid; } i=n;sum=0; while(i<=m){ if(i%3==0){ sum=sum+i;} i++; } printf("%d",sum); return 0; }
Problem1054:#include int main() { int i,sum,n; scanf("%d",&n); while(n>=6){ sum=0; for(i=1;i int main() { int m,i,sum=0; scanf("%d",&m); for(;m>=6;m) { sum=0; for(i=1;i #include int main() { int x,y,z,mid,i,j,m; scanf("%d%d",&x,&y); m=x*y; if(x #include int main() { int x,m,n,s,i,j,k,mid,sum,center; scanf("%d%d",&m,&n); if(m>n){center=m;m=n;n=center;} s=m;x=0; while(s<=n){ i=s%10; mid=s/10; j=mid%10; k=mid/10; sum=pow(i,3)+pow(j,3)+pow(k,3); if(sum==s) {printf("%d\n",sum); x++;} s++; } if(x==0) printf("No"); return 0; } 
Problem1056:#include int main() { int m,n,mid,i,j,k,sum,a; scanf("%d%d",&m,&n); k=0; if(m>n){mid=m;m=n;n=mid;} for(i=m;i<=n;i++) { sum=0; a=i; for(;a!=0;) { j=a%10; sum=sum+j*j*j; a=a/10; } if(sum==i){ printf("%d\n",sum); k++; } } if(k==0){ printf("No"); } return 0; }
Problem1056:#include #include int main() { int m,n,i,a,b,c,x=0; scanf("%d%d",&m,&n); for(i=m;i<=n;i++) {a=i%10; b=(i/10)%10; c=i/100; if(i==pow(a,3)+pow(b,3)+pow(c,3)) {x++; printf("%d\n",i);} } if(x==0){ printf("No");} return 0; } 
Problem1057:#include #include int main() { double s,m; int n,i; scanf("%d",&n); m=pow(2,n);i=1; while(s //#include int main() { int n; double sum,i; scanf("%d",&n); sum=0;i=1; do{ sum=(1/(i*(i+1)))+sum; i++; }while(i<=n); printf("%lf",sum); return 0; } 
Problem1058:#include int main() { int n; double i,sum; scanf("%d",&n); i=1;sum=0; while(i<=n){ sum=sum+(1/(i*(i+1))); i++; } printf("%lf",sum); return 0; }
Problem1059:#include //#include int main() { int n; double sum; scanf("%d",&n); sum=1; do{ sum=(n%10)*sum; n=n/10; }while(n%10!=0); printf("%.lf",sum); return 0; } 
Problem1059:#include int main() { int n,i; double s; scanf("%d",&n); s=1; do{ i=n%10; s=s*i; n=n/10; }while(n!=0); printf("%.0lf",s); return 0; }
Problem1060:#include //#include int main() { double a,i,j,k; scanf("%lf",&a); i=1; do{ j=0.5*(i+a/i); i=j; k++; }while(k<=10000000); printf("%lf",i); return 0; } 
Problem1067:#include int main() { int a[2],sum,i,t; while(scanf("%d",&a[0])!=EOF) { for(i=1;i<2;i++) scanf("%d",&a[i]); sum=0; for(i=0;i<2;i++) sum=sum+a[i]; printf("%d\n",sum); printf("\n"); } return 0; } 
Problem1068:#include #include int main() { int sum,t,n,i,mid; scanf("%d",&t); while(t) { scanf("%d",&n); sum=0; for(i=1;i<=n;i++) { scanf("%d",&mid); sum=sum+mid; } printf("%d\n",sum); putchar('\n'); } return 0; } 
Problem1076:#include int main() { int i,j,n,m; double s; scanf("%d",&n); i=1; while(i<=n){ s=1; scanf("%d",&m); while(m!=0) { j=m%10; m=m/10; s=s*j; }if(i!=n) printf("%.0lf\n",s); else printf("%.0lf",s); i++; } return 0; }
Problem1076:#include int main() { int a,b,c,d,x,i,m; double sum; scanf("%d",&a); for(m=1;m<=a;m++) { scanf("%d",&b); sum=1; while(b!=0) { x=b%10; sum=sum*x; b=b/10; } printf("%.0lf\n",sum); } return 0; }
Problem1086:#include int main() { double sum,m,n; int a,i; scanf("%d",&a); for(i=1;i<=a;i++){ scanf("%lf%lf",&n,&m); sum=0; for(;n<=m;n++){ sum=sum+1/(n*n); } printf("%.5lf\n",sum); } return 0; }
Problem1089:#include int main () { int N,i,j,k,s; scanf("%d",&N); while (N!=0) { i=1; s=0; while(N!=0) { k=N%2; j=k*i; i=i*10; N=N/2; s=s+j; } printf ("%d\n",s); scanf("%d",&N); } return 0; } 
Problem1089:#include int main() { int x,b[16],n,k,r,i=0,a; scanf("%d",&n); while(n!=0){ k=1; while(n!=0) { r=n%2; b[++k]=r; n/=2;} for(i=k;i>=0;i) printf("%d",b[i]); printf("\n"); scanf("%d",&n); } return 0; } 
Problem1094:#include int main() { int i,j,n,m; double s; scanf("%d",&n); i=1; while(i<=n){ scanf("%d",&m); s=1; for(j=1;j<=m;j++){ s=s*j; }if(i==n) { printf("%.lf",s); } else printf("%.lf\n",s); i++; } return 0; }
Problem1094:#include int main() { int n,i,j,m; double s; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&m); for(j=1,s=1;j<=m;j++){ s=s*j; } if(i==n) printf("%.0lf",s); else printf("%.0lf\n",s); } return 0; } 
Problem1097:#include int main() { int i,j,k; double T,n,a[30],sum,ava; scanf("%lf",&T); while(T) { sum=0; k=0; scanf("%lf",&n); for(i=0;iava) k++; } printf("%.2lf %d\n",ava,k); } return 0; } 
Problem1097:#include int main() { int i,n,T,x,j; int a[30]; double sum,ave; scanf("%d",&T); for(i=1;i<=T;i++) { sum=0; x=0; scanf("%d",&n); for(j=0;jave) x++; } printf("%.2lf %d\n",ave,x); } return 0; } 
Problem1098:#include int main() { int t,m,n,i,k,x,a[10]; scanf("%d",&t); while(t) { scanf("%d",&m); for(i=0;i int main() { int a[10],b[10],c[20],m,n,i,j,t,T; T=2; while(T) { scanf("%d%d",&m,&n); for(i=0;ic[j]) { t=c[i]; c[i]=c[j]; c[j]=t; } } for(i=0;i int main() { int m,i,j,a[20],max; scanf("%d",&m); while(m!=0) { for(i=0;imax){max=a[i]; j=i;} } printf("%d %d\n",max,j); scanf("%d",&m); } return 0; }
Problem1102:#include int main() { int n,i,j,max; int a[20]; scanf("%d",&n); while(n!=0) { for(i=0;imax){ max=a[i]; j=i;} } printf("%d ",max); printf("%d\n",j); scanf("%d",&n); } return 0; } 
Problem1102:#include int main() { int j,max,i,n,a[20]; scanf("%d",&n); while(n!=0) { for(j=0;j int main() { int i,j,t,a[10]; while(scanf("%d",&a[0])!=EOF) { for(i=1;i<10;i++) scanf("%d",&a[i]); for(i=0;i<9;i++) for(j=i+1;j<10;j++) { if(a[i]>a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } for(i=0;i<10;i++) if(i==9) printf("%d\n",a[i]); else printf("%d ",a[i]); } return 0; }
Problem1104:#include int main() { int i,n,a[10],max,min; double sum,ave; while(scanf("%d",&a[0])!=EOF) { sum=0; for(i=1;i<10;i++) scanf("%d",&a[i]); max=a[0]; min=a[0]; for(i=0;i<10;i++) { if(max<=a[i]) max=a[i]; if(min>=a[i]) min=a[i]; sum=sum+a[i]; } sum=summaxmin; ave=sum/8; printf("%.2lf\n",ave); } return 0; }
Problem1105:#include int main() { int m,i,j,a[20],t; scanf("%d",&m); while(m!=0) { for(i=0;i int main() { int i,n,t,a[20]; scanf("%d",&n); while(n!=0) { for(i=0;i int main() { int a[10][10],i,j,max,row,col,N; scanf("%d",&N); for(i=0;imax) { max=a[i][j]; row=i; col=j; } printf("%d %d %d",max,row,col); return 0; } 
Problem1106:#include int main() { int a[10][10],i,j,n,row=0,col=0,max; scanf("%d",&n); for(i=0;imax) { max=a[i][j]; row=i; col=j; } printf("%d %d %d",max,row,col); return 0; } 
Problem1107:#include int main() { int a[10][10],sum,i,j,N; scanf("%d",&N); for(i=0;i int main() { int n,i,j,k,t,a[20]; scanf("%d",&n); while(n!=0) { for(i=0;i int main() { int a[10][10],b[10][10],c[10][10],m,n,i,j; scanf("%d%d",&m,&n); while(m!=0||n!=0) { for(i=0;i int main() { int m,n,i,j,t,a[10][10]; while(scanf("%d%d",&m,&n)!=EOF) { for(i=0;i #include #include int main() { int a[10][10],t,i,j,m,n; while(scanf("%d%d",&m,&n)!=EOF) { for(i=0;i int main() { int a[10][10],n,i,j,flag; scanf("%d",&n); while(n!=0) { flag=0; for(i=0;i int main() { int a[100][100]; int m,i,j,flag; while(scanf("%d",&m)&&m!=0) { flag=0; for(i=0;i int main() { int t,n,i,k,a[10]; scanf("%d",&t); while(t) { k=0; for(i=0;i<10;i++) scanf("%d",&a[i]); scanf("%d",&n); for(i=0;i<10;i++) if(n+30>=a[i]) k++; printf("%d\n",k); } return 0; } 
Problem1115:#include int main() { int t,m,n,i,a[90]; scanf("%d",&t); while(t) { scanf("%d",&n); for(i=0;i int main() { int a[10][10],b[10][10],n,i,j,T; scanf("%d",&T); while(T) { scanf("%d",&n); for(i=0;i int main() { int t,n,i,j,c; int a[10][10]; int b[10][10]; scanf("%d",&t); for(c=0;c int main(){ int t; scanf("%d",&t); while(t){ int n,a[100][100],q=0; scanf("%d",&n); for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ scanf("%d",&a[i][j]); } } q=(n+1)/2; for(int p=1;p<=q;p++){ for(int i=p,j=p;j<=np;j++) printf("%d ",a[i][j]); for(int i=p,j=n+1p;i<=np;i++) printf("%d ",a[i][j]); for(int i=n+1p,j=n+1p;j>=p+1;j) printf("%d ",a[i][j]); for(int i=n+1p,j=p;i>=p+1;i){ if(n==2*p) printf("%d",a[i][j]); else printf("%d ",a[i][j]); } if(p==q&&n%2==1) printf("%d",a[(n+1)/2][(n+1)/2]); } printf("\n"); } }
Problem1119:#include #include #include int prime(int x); int main() { int m,n,t,i,count,mid; while(scanf("%d%d",&m,&n)!=EOF) { count=0; if(m>n){t=m;m=n;n=t;} for(i=m;i<=n;i++) if(prime(i)==1) count++; printf("%d\n",count); } return 0; } int prime(int x) { int i,k; k=sqrt(x)+1; for(i=2;i<=k;i++) if(0==x%i&&k!=2) return 0; return 1; } 
Problem1121:#include int main() { int T,t,n,i,j,k,a[100]; scanf("%d",&T); while(T) { k=0; scanf("%d",&n); for(i=0;ia[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; k++; } } } printf("%d\n",k); } return 0; } 
Problem1123:#include int main() { char a[100]; while(gets(a)!=NULL) puts(a); return 0; }
Problem1124:#include int main() { char a[100]; int i,x,b,c,d,e; while(gets(a)!=NULL) { x=b=c=d=e=0; for(i=0;a[i]!='\0';i++) { if(a[i]>='A'&&a[i]<='Z') x++; else if(a[i]>='a'&&a[i]<='z') b++; else if(a[i]>='0'&&a[i]<='9') c++; else if(a[i]==' ') d++; else e++; } printf("%d %d %d %d %d\n",x,b,c,d,e); } return 0; }
Problem1125:#include int main() { int i,j; char s[200]; while(gets(s)!=NULL) { j=0; for(i=0;s[i]!='\0';i++) if(s[i]!=' '&&(s[i+1]==' '||s[i+1]=='\0')) j++; printf("%d\n",j); } return 0; } 
Problem1126:#include int main() { char a[200],b[200]; int t,i,k; scanf("%d",&t); getchar(); while(t) { gets(a); for(i=0;a[i]!='\0';i++) if(a[i]>='a'&&a[i]<='z') a[i]=a[i]32; puts(a); for(i=0;a[i]!='\0';i++) if(a[i]>='A'&&a[i]<='Z') a[i]=a[i]+32; puts(a); } return 0; } 
Problem1127:#include #include int main() { int i,j,t,n,max,mid; char s[100],b[100]; scanf("%d",&t); while(t) { scanf("%d\n",&n); gets(s); max=strlen(s); for(i=0;s[i]!='\0';i++) b[i]=s[i]; b[i]='\0'; for(;0!=n1;n) { gets(s); mid=strlen(s); if(mid>max) { max=mid; for(i=0;s[i]!='\0';i++) b[i]=s[i]; b[i]='\0'; } } puts(b); } return 0; } 
Problem1129:#include #include int main() { int i,t,n; char s[100],b[100]; scanf("%d",&t); while(t) { scanf("%d",&n); getchar(); gets(b); while(1!=n) { gets(s); if(strcmp(s,b)>0) strcpy(b,s); } puts(b); } return 0; } 
Problem1130:#include #include int main() { int i,t,n; char s[100],b[100]; scanf("%d",&t); while(t) { scanf("%d",&n); getchar(); gets(b); while(1!=n) { gets(s); if(strcmp(s,b)<0) strcpy(b,s); } puts(b); } return 0; } 
Problem1131:#include int main() { char a[100],b[100]; int t,i,j,m,n; scanf("%d",&t); while(t) { scanf("%d%d\n",&m,&n); gets(a); j=0; for(i=m;i<=n;i++) b[j++]=a[i]; b[j]='\0'; puts(b); } return 0; }
Problem1131:#include int main() { int m,n,i,k,t,j; char c[100],b[100]; scanf("%d",&t); i=0; while(i int main() { char c[100],a[100]; int T,i,m,n; scanf("%d",&T); while(T!=0) { scanf("%d%d\n",&m,&n); gets(c); for(i=m;i<=n;i++) a[im]=c[i]; a[im]='\0'; puts(a); T; } return 0; } 
Problem1131:#include int main() { char c[100],a[100]; int T,i,m,n; scanf("%d",&T); while(T!=0) { scanf("%d%d",&m,&n); getchar(); gets(c); for(i=m;i<=n&&c[i]!='\0';i++) a[im]=c[i]; a[im]='\0'; puts(a); T; } return 0; } 
Problem1132:#include #include int main() { char c[100],a[100]; int T,i,k; scanf("%d",&T); getchar(); while(T) { gets(c); strcpy(a,c); k=strlen(a); gets(c); for(i=k,k=0;c[k]!='\0';k++) { a[i++]=c[k]; } a[i]='\0'; puts(a); } return 0; } 
Problem1133:#include #include int main() { int i,j,t,n; char s[100],b[100]; scanf("%d",&t); getchar(); while(t) { gets(s); j=0; for(i=0;s[i]!='\0';i++) if(s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z') b[j++]=s[i]; b[j]='\0'; puts(b); } return 0; } 
Problem1134:#include #include int main() { int i,t,k; char s[100],b[100],n; while(gets(s)!=NULL) { k=0; scanf("%c",&n); getchar(); for(i=0;s[i]!='\0';i++) { if(s[i]==n) continue; b[k++]=s[i]; } b[k]='\0'; puts(b); } return 0; } 
Problem1134:#include #include int main() { char a[100],b[100];char n;int i,j; while(gets(a)!=NULL) { j=0; //memset(b,0,sizeof(b)); scanf("%c",&n); getchar(); for(i=0;a[i];i++) { if(a[i]!=n) b[j++]=a[i]; } b[j]='\0'; puts(b); } return 0; } 
Problem1136:#include #include int main() { char a[100],b[100]; int i,k,j; while(gets(a)!=NULL) { strcpy(b,a); k=strlen(a); j=0; for(i=0;i<=k/2+1;i++) { if(a[i]!=b[k1i]&&a[i]!=b[k1i]+32&&a[i]+32!=b[k1i]) j++; } if(0==j) printf("Yes\n"); else printf("No\n"); } return 0; } 
Problem1136:#include #include int main() { char a[100],b[100]; int i,k,j; while(gets(a)!=NULL) { strcpy(b,a); k=strlen(a); j=0; for(i=0;a[i]!='\0';i++) { if(a[i]!=b[k1i]&&a[i]!=b[k1i]+32&&a[i]+32!=b[k1i]) j++; } if(0==j) printf("Yes\n"); else printf("No\n"); } return 0; } 
Problem1136:#include #include int main() { char a[100],b[100]; int i,k; while(gets(a)!=NULL) { strcpy(b,a); k=strlen(a); for(i=0;a[i]!='\0';i++) { if(a[i]!=b[k1i]&&a[i]!=b[k1i]+32&&a[i]+32!=b[k1i]) break; } if(k==i) printf("Yes\n"); else printf("No\n"); } return 0; } 
Problem1137:#include #include #include #include char s[400]; int judge(int pos1,int pos2) { if(s[pos1]==s[pos22]&&s[pos1+1]==s[pos21]&&s[pos1+2]==s[pos2]) return 1; else return 0; } int main() { int l,r,flag,n; while (gets(s)!= NULL) { flag=1; n=strlen(s); l=0; r=n1; while(l #include #include int main() { char str[100000];int count=0; char x[100000]; while(gets(str)!=NULL) { int i; count=0; memset(x,0,sizeof(x)); int l=strlen(str); for(i=0;i #include #include int prime(int x); int main() { char t,a[100]; int count,i; while(scanf("%c",&t)!=EOF) { if(t>='a'&&t<='z') t=t32; gets(a); count=0; for(i=0;a[i];i++) { if(a[i]>='a'&&a[i]<='z') a[i]=a[i]32; if(t==a[i]) count++; } printf("%d\n",count); } return 0; } 
Problem1146:#include int main() { int a[100],i,j,n,s,t,mid; while(scanf("%d",&n)!=EOF) { scanf("%d%d",&s,&t); for(i=0;i int main() { int a[32],i,m,t; while(scanf("%d",&m)!=EOF) { if(m==0) printf("%d",m); for(i=0;m!=0;i++) { a[i]=m%2; m=m/2; } while(i) printf("%d",a[i]); putchar('\n'); } return 0; } 
Problem1149:#include int main() { int i,m,n,t; char a[32]; while(scanf("%d%d",&m,&n)!=EOF) { if(m==0) printf("%d",m); for(i=0;m!=0;i++) { if(m%n<=9) a[i]=m%n+'0'; else a[i]=m%n10+'A'; m=m/n; } while(i) printf("%c",a[i]); putchar('\n'); } return 0; } 
Problem1150:#include #include #include int main() { int i,j; double m; int b[100]; char a[40]; while(gets(a)!=NULL) { m=0; j=0; for(i=0;a[i]!='\0';i++) if(a[i]=='0') b[j++]=0; else b[j++]=1; for(i=0;i #include #include int main() { int i,j,b,c[100]; char a[100]; while(gets(a)!=NULL) { b=0; for(i=0;a[i]!='\0';i++) if(a[i]>='0'&&a[i]<='9') b=(a[i]48)+b*10; if(b==0) printf("%d %d\n",b,b); else { printf("%d ",b); for(i=0;b!=0;i++) { c[i]=b%2; b=b/2; } while(i) printf("%d",c[i]); putchar('\n'); } } return 0; } 
Problem1153:#include #include int main() { char a[100],b[100]; int i,k,j,flag; while(gets(a)!=NULL) { k=0; b[k++]=a[0]; b[k]='\0'; for(i=1;a[i]!='\0';i++) { flag=0; for(j=0;b[j]!='\0';j++) { if(a[i]!=b[j]) flag++; } if(flag==k) b[k++]=a[i]; b[k]='\0'; } puts(b); } return 0; } 
Problem1153:#include int main() { char a[100]={0},b[100]={0}; int i,j,flag; while(gets(a)!=NULL) { flag=0; for(i=0;a[i];i++) { for(j=0;b[j];j++) if(a[i]!=b[j]) flag++; if(flag==j) b[j]=a[i]; flag=0; } puts(b); for(i=0;b[i];i++) b[i]='\0'; } return 0; }
Problem1157:#include #include #include int main() { int m,n,i,k; char a[100],b[100]; while(scanf("%d%d",&m,&n)!=EOF) { k=0; getchar(); gets(a); for(i=0;a[i]!='\0';i++) { if(i>=m&&i<=m+n1) continue; b[k++]=a[i]; } b[k]='\0'; puts(b); } return 0; } 
Problem1162:#include double ave(double x,double y); int main() { double a,b,aveage; while(scanf("%lf%lf",&a,&b)!=EOF) { aveage=ave(a,b); printf("%.1lf\n",aveage); } return 0; } double ave(double x,double y) { double ave; ave=(x+y)/2; return ave; } 
Problem1166:#include char arc(char x); int main() { char a,b; while(scanf("%c",&a)!=EOF) { getchar(); b=arc(a); if(b=='0') printf("Digit\n"); else printf("Other\n"); } return 0; } char arc(char x) { if(x>='0'&&x<='9') return '0'; return '1'; } 
Problem1178:#include int main() { char a[1000],b[1000],c[100]; int i,j,k,sum,t,m; while(gets(a)!=NULL) { k=0; for(i=0;a[i];) { if(a[i]==a[i+1]) { sum=1; for(j=i;a[j]==a[j+1];j++) sum++; if(sum>=10) { t=0; do{ c[t++]=sum%10; sum=sum/10; }while(sum!=0); for(m=0;m #include int main() { int n,ans; while(scanf("%d",&n)!=EOF) { ans=n*(n+1)/2+1; printf("%d\n",ans); } return 0; } 
Problem1182:#include int prime(int x); int main() { int m,a; while(scanf("%d",&m)!=EOF) { a=prime(m); if(a==1) printf("Yes\n"); else printf("No\n"); } return 0; } int prime(int x) { int i,k; k=sqrt(x)+1; for(i=2;i<=k;i++) if(0==x%i&&k!=2) return 0; return 1; } 
Problem1183:#include int sum(int x); int main() { int a,b; while(scanf("%d",&a)!=EOF) { b=sum(a); printf("%d\n",b); } return 0; } int sum(int x) { int sum; sum=0; do{ sum=sum+(x%10); x=x/10; }while(x!=0); return sum; } 
Problem1184:#include int s(int x,int y); int main() { int a,b,m,n; while(scanf("%d%d",&m,&n)!=EOF) { a=s(m,n); b=m*n/a; printf("%d %d\n",a,b); } return 0; } int s(int x,int y) { int t,mid; if(x>y){t=x;x=y;y=t;} do{ mid=y%x; y=x; x=mid; }while(x!=0); return y; } 
Problem1185:#include int main() { printf("This is a C program.\n"); return 0; } 
Problem1186:#include #include #include double jc(int m,int n); int main() { printf("I am a student!\n"); printf("I love China!\n"); return 0; } 
Problem1190:#include int mul(int a,int b,int c); int main() { int a,b,c,sum; scanf("%d%d%d",&a,&b,&c); sum=mul(a,b,c); printf("%d",sum); return 0; } int mul(int a,int b,int c) { return(a*b*c); } 
Problem1191:#include int main() { int a,b,sum; scanf("%d%d",&a,&b); sum=a+b; printf("%d",sum); return 0; } 
Problem1192:#include int main() { double a,b,c,ave; scanf("%lf%lf%lf",&a,&b,&c); ave=(a+b+c)/3; printf("%.2lf",ave); return 0; } 
Problem1194:#include int sum(int m,int n[]); int main() { int m,n[30]={1,1},i; scanf("%d",&m); sum(m,n); for(i=0;i2) { sum(m1,n); sum(m2,n); n[m1]=n[m2]+n[m3]; } else return 1; } 
Problem1194:#include void sum(int m,int n[]); int main() { int m,n[30]={1,1},i; scanf("%d",&m); sum(m,n); for(i=0;i2) { sum(m1,n); sum(m2,n); n[m1]=n[m2]+n[m3]; } } 
Problem1194:#include int fib(int x) {if(x>2) return(fib(x1)+fib(x2)); else if(x==1||x==2) return 1; } int main() {int i,j,c; scanf("%d",&c); for(i=1;i int integer;double renu; void fj(double m); int main() { double m; while(scanf("%lf",&m)!=EOF) { fj(m); printf("%d %lf\n",integer,renu); } return 0; } void fj(double m) { integer=m; renu=minteger; } 
Problem1199:#include int main() { printf(" *\n ***\n*****\n ***\n *"); return 0; } 
Problem1200:#include int main() { printf("*****\n ***\n *\n ***\n*****"); return 0; }
Problem1201:#include int main() { printf("* * * * * *\n * * * * *\n * * * *\n * * *\n * *\n *"); return 0; } 
Problem1202:#include int main() { printf("XYXYXY\nXYXYX\nXYXY\nXYX\nXY\nX"); return 0; } 
Problem1203:#include double sn(double x); int main() { double a,m,n; scanf("%lf",&m); while(m!=0) { a=sn(m); printf("%lf\n",a); scanf("%lf",&m); } return 0; } double sn(double x) { double i,sn; sn=0; for(i=1;i<=x;i++) sn=sn+1/((i+1)*i); return sn; } 
Problem1204:#include int sum(int x); int main() { int a,b,m,n; while(scanf("%d",&m)!=EOF) { a=sum(m); printf("%d\n",a,b); } return 0; } int sum(int x) { int a[100]={1,1},i,sum; for(i=2;i double sn(double x); int main() { double a,m,n; while( scanf("%lf",&m)!=EOF) { a=sn(m); printf("%lf\n",a); } return 0; } double sn(double x) { double b[100]={1,2},sn; int i; sn=0; for(i=0;i<=x1;i++) { sn=sn+b[i+1]/b[i]; b[i+2]=b[i+1]+b[i]; } return sn; } 
Problem1207:#include double sum(int n); int main() { int n; while(scanf("%d",&n)!=EOF) printf("%lf\n",sum(n)); return 0; } double sum(int n) { double s=0; double i; for(i=1;i<=n;i++) s=s+(2*i1)*(2*i+1)/(2*i)/(2*i); return s; } 
Problem1211:#include int comp(int x,int y); int main() { int m,n,sum; while(scanf("%d%d",&m,&n)&&m!=0&&n!=0) { sum=comp(m,n); printf("%d\n",sum); } return 0; } int comp(int x,int y) { int a,b,c,d,z; a=x/10; b=x%10; c=y/10; d=y%10; z=a*100+b+c*10+d*1000; return z; } 
Problem1212:#include #include long long comp(long long x); int main() { long long m,n; scanf("%lld",&m); while(m!=0) { n=comp(m); printf("%lld\n",n); scanf("%lld",&m); } return 0; } long long comp(long long x) { int i,t,sum=0,con; i=0;con=0; while(x!=0) { con++; if(con%2==1) { sum=sum+x%10*pow(10,i); i++; } x=x/10; } return sum; } 
Problem1214:#include #include double s(double x,double y,double z); int main() { double x,y,z; while(scanf("%lf%lf%lf",&x,&y,&z)!=EOF) printf("%.2lf\n",s(x,y,z)); return 0; } double s(double x,double y,double z) { double f; f=(x+y)/(xy)+(z+y)/(zy); return f; } 
Problem1215:#include #include double s(double x); int main() { double n; while(scanf("%lf",&n)&&n!=0) printf("%lf\n",s(n)); return 0; } double s(double x) { int i; double s0; s0=0; for(i=1;i<=x;i++) s0=s0+pow(1,i1)*(2*i1)*(2*i+1)/pow(2*i,2); return s0; } 
Problem1217:#include #include double s(double x); int main() { double n; while(scanf("%lf",&n)!=EOF) printf("%lf\n",s(n)); return 0; } double s(double x) { int i; double s0=1,t; for(i=1,t=1;;i++) { t=t*i/(2*i+1); if(t>=x) s0=s0+t; else break; } return 2*s0; } 
Problem1218:#include int sn(int x,int y); int main() { int a,m,n; scanf("%d%d",&m,&n); while(m!=0&&0!=n) { a=sn(m,n); printf("%d\n",a); scanf("%d%d",&m,&n); } return 0; } int sn(int x,int y) { int i,j,k,mid,sn; i=x%10; j=x/10; k=y%10; mid=y/10; sn=j*1000+i*10+k*100+mid; return sn; } 
Problem1227:#include void s(char a[],char b[]); int main() { char a[1000],b[1000]; int t; scanf("%d",&t); getchar(); while(t) { gets(a); s(a,b); puts(b); } return 0; } void s(char a[],char b[]) { int i,k=0; for(i=0;a[i]!='\0';) { b[k++]=a[i++]; if(i%3==0) b[k++]=' '; } b[k]='\0'; } 
Problem1228:#include #include void s(char a[],char c[]); int main() { char a[100],c[100]; int t; scanf("%d",&t); getchar(); while(t) { gets(a); s(a,c); puts(c); } return 0; } void s(char a[],char c[]) { char b[100]; int i,k=0,j=0; for(i=0;a[i]!='\0';i++) { if(a[i]>='0'&&a[i]<'9') b[k++]=a[i]; else c[j++]=a[i]; } b[k]='\0'; c[j]='\0'; strncat(c,b,k); } 
Problem1230:#include int main() { int x,*p; p=&x; while(scanf("%d",p)!=EOF) { while(*p>=10) *p=*p/10; printf("%d\n",*p); } return 0; } 
Problem1235:#include int main() { int n,a[20],*p1,*p2,i,t; while(scanf("%d",&n)&&n!=0) { for(i=0;i #include int main() { int m,i,mid; scanf("%d",&m); mid=sqrt(m); for(i=2;i<=mid+1;i++) { if(m%i==0) break; } if(i>mid+1) printf("Prime"); else printf("Not prime"); return 0; }
Problem1241:#include void s(char *p); int main() { char a[100]; while(gets(a)!=NULL) { s(a); puts(a); } return 0; } void s(char *p) { int i; for(i=0;*(p+i);i++) if(*(p+i)>='a'&&*(p+i)<='z') *(p+i)=*(p+i)32; } 
Problem1243:#include int main() { double sum=0,i; int n; scanf("%d",&n); for(i=1;i<=n;i++) sum=sum+1/(2*i1)1/(2*i); printf("%.4lf",sum); return 0; }
Problem1245:#include int main() { int i,j,k; for(i=1;i<=6;i++) { for(j=6i;j>0;j) putchar(' '); for(k=1;k<=2*i1;k++) putchar('*'); putchar('\n'); } for(i=1;i<=5;i++) { for(j=1;j<=i;j++) putchar(' '); for(k=1;k<=2*(5i)+1;k++) putchar('*'); putchar('\n'); } return 0; }
Problem1247:#include #include struct student { char num[10]; char name[10]; int s1; int s2; int s3; int s4; }st1,st2,st3; int main() { scanf("%s%s",&st1.num,&st1.name); scanf("%d%d%d%d",&st1.s1,&st1.s2,&st1.s3,&st1.s4); printf("%s %d\n",st1.num,st1.s2+st1.s3+st1.s4); scanf("%s%s",&st2.num,&st2.name); scanf("%d%d%d%d",&st2.s1,&st2.s2,&st2.s3,&st2.s4); printf("%s %d\n",st2.num,st2.s2+st2.s3+st2.s4); scanf("%s%s",&st3.num,&st3.name); scanf("%d%d%d%d",&st3.s1,&st3.s2,&st3.s3,&st3.s4); printf("%s %d\n",st3.num,st3.s2+st3.s3+st3.s4); return 0; } 
Problem1248:#include #include struct teacher { char num[10]; char name[10]; char posi[10]; int s1; int s2; int s3; int s4; int s5; int s6; }te1,te2,te3; int main() { scanf("%s%s%s",&te1.num,&te1.name,&te1.posi); scanf("%d%d%d%d%d%d",&te1.s1,&te1.s2,&te1.s3,&te1.s4,&te1.s5,&te1.s6); if(te1.s1+te1.s2+te1.s3>5000) printf("姓名:%s,出生日期:%d.%d.%d,工资:%d\n",te1.name,te1.s4,te1.s5,te1.s6,te1.s1+te1.s2+te1.s3); scanf("%s%s%s",&te2.num,&te2.name,&te2.posi); scanf("%d%d%d%d%d%d",&te2.s1,&te2.s2,&te2.s3,&te2.s4,&te2.s5,&te2.s6); if(te2.s1+te2.s2+te2.s3>5000) printf("姓名:%s,出生日期:%d.%d.%d,工资:%d\n",te2.name,te2.s4,te2.s5,te2.s6,te2.s1+te2.s2+te2.s3); scanf("%s%s%s",&te3.num,&te3.name,&te3.posi); scanf("%d%d%d%d%d%d",&te3.s1,&te3.s2,&te3.s3,&te3.s4,&te3.s5,&te3.s6); if(te3.s1+te3.s2+te3.s3>5000) printf("姓名:%s,出生日期:%d.%d.%d,工资:%d\n",te3.name,te3.s4,te3.s5,te3.s6,te3.s1+te3.s2+te3.s3); return 0; } 
Problem1250:#include #include struct student { char num[10]; char name[10]; int score; }st[8]; int main() { int i,max,mid; for(i=0;i<8;i++) scanf("%s%s %d",&st[i].num,&st[i].name,&st[i].score); max=0;mid=st[0].score; for(i=1;i<8;i++) if(st[i].score>mid) { max=i; mid=st[i].score; } printf("%s %s %d",st[max].num,st[max].name,st[max].score); return 0; } 
Problem1250:#include #include struct student { char num[10]; char name[10]; int score; }st[8]; int main() { int i,max,mid; for(i=0;i<8;i++) scanf("%s%s %d",st[i].num,st[i].name,&st[i].score); max=0;mid=st[0].score; for(i=1;i<8;i++) if(st[i].score>mid) { max=i; mid=st[i].score; } printf("%s %s %d",st[max].num,st[max].name,st[max].score); return 0; } 
Problem1252:#include #include #include struct score* creat(); void list(struct score *head); typedef struct score { int fs; struct score *next; }CJ; int main() { CJ *h=NULL; h=creat(); list(h); return 0; } CJ* creat() { CJ *p,*head; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); p>next=NULL; while(p>fs!=0) { head=p; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); p>next=head; } free(p); return(head); } void list(CJ *head) { CJ *p; p=head; while(p!=NULL) { if(p>next==NULL) printf("%d",p>fs); else printf("%d ",p>fs); p=p>next; } }
Problem1253:#include #include int main() { int *p=NULL,n,i; while(scanf("%d",&n)!=EOF) { p=(int*)malloc(n*4); for(i=0;i void s(int *p,int *p1); int main() { int a[100],i,n,t; t=2; while(t) { scanf("%d",&n); for(i=0;i*(p+j)) { t=*(p+i); *(p+i)=*(p+j); *(p+j)=t; } } 
Problem1277:#include int s(char *p); int main() { char a[100]; int t; scanf("%d",&t); getchar(); while(t) { gets(a); printf("%d\n",s(a)); } return 0; } int s(char *p) { int i,j=0; for(i=0;*(p+i);i++) if(*(p+i)>='a'&&*(p+i)<='z') *(p+i)=*(p+i)32; for(i=0;*(p+i);i++) if(*(p+i)=='A'||*(p+i)=='E'||*(p+i)=='I'||*(p+i)=='O'||*(p+i)=='U') j++; return j; } 
Problem1283:#include int main() { char a[100]; gets(a); puts(a); return 0; }
Problem1284:#include int main() { char a[100]; int i,x,b,c,d,e; gets(a); x=b=c=d=e=0; for(i=0;a[i]!='\0';i++) { if(a[i]>='A'&&a[i]<='Z') x++; else if(a[i]>='a'&&a[i]<='z') b++; else if(a[i]>='0'&&a[i]<='9') c++; else if(a[i]==' ') d++; else e++; } printf("%d %d %d %d %d",x,b,c,d,e); return 0; }
Problem1286:#include int main() { char a[100],b[100],c[200]; int i,j,x; x=0; gets(a); gets(b); for(i=0;a[i]!='\0';i++) c[x++]=a[i]; for(j=0;b[j]!='\0';j++) c[x++]=b[j]; c[x]='\0'; puts(c); return 0; }
Problem1289:#include #include int s(int *p,int *q); int main() { int i,n,a[100]; scanf("%d",&n); for(i=0;i void s(int *p,int *q); int main() { int i,n,a[100]; scanf("%d",&n); for(i=0;i*(p+j)) { t=*(p+i); *(p+i)=*(p+j); *(p+j)=t; } } 
Problem1291:#include #include void s(char *p1,char *p2); int main() { char a[100],b[100]; gets(a); gets(b); s(a,b); puts(a); return 0; } void s(char *p1,char *p2) { strcat(p1,p2); } 
Problem1292:#include int main() { int a,b,mid; scanf("%d %d",&a,&b); mid=a; a=b; b=mid; printf("%d %d",a,b); return 0; }
Problem1293:#include #include #include int main() { double a,b,c,p,area; scanf("%lf%lf%lf",&a,&b,&c); p=(a+b+c)/2; area=sqrt(p*(pa)*(pb)*(pc)); printf("%lf",area); return 0; } 
Problem1297:#include int main() { int a; scanf("%d",&a); if(a%3==0&&a%5==0) printf("该数能同时被3和5整除"); else if(a%3==0||a%5==0) printf("该数能被其中一个数整除"); else printf("该数既不能被3整除也不能被5整除"); return 0; } 
Problem1300:#include int main() { int n,i,j; scanf("%d",&n); i=1; while(i<=(n+1)/2) { for(j=1;j<=(n+1)/2i;j++){ putchar(' ');} for(j=1;j<=2*i1;j++){ putchar('#');} printf("\n"); i++; } i=1; while(i<=(n1)/2){ if(i==(n1)/2){ for(j=1;j<=i;j++){ putchar(' '); } for(j=1;j<=n2*i;j++){ putchar('#'); }} else{ for(j=1;j<=i;j++){ putchar(' '); } for(j=1;j<=n2*i;j++){ putchar('#'); }printf("\n");} i++; } return 0; }
Problem1301:#include int main() { int n,i,sum=0; scanf("%d",&n); for(i=1;i<=n;i++) if(i%3==0&&i%7!=0) sum=sum+i; printf("%d",sum); return 0; } 
Problem1302:#include #include using namespace std; int main() { int s1[2000], s2[2000]; double sum = 1, pi = 0; int m = 0, n = 0; for (int i = 1; i <= 2000; i++) { if ((i & 1) == 0) { s1[m++] = i; s1[m++] = i; } else { if (i != 1) { s2[n++] = i; s2[n++] = i; } else s2[n++] = i; } } int num; cin >> num; for (int i = 0; i < num; i++) sum *= (static_cast(s1[i]) / static_cast(s2[i])); pi = 2 * sum; cout << fixed << setprecision(6) << pi << endl; return 0; } 
Problem1323:#include struct student { char num[16]; char name[32]; int score; }st[100],t; int main() { int n,i,j; while(scanf("%d",&n)!=EOF) { for(i=0;i #include struct book { char a[14]; char b[200]; char c[200]; double d; }bk[100]; int main() { int n,i,mid; char cz[14]; while(scanf("%d",&n)!=EOF) { mid=0; getchar(); for(i=0;i #include #include int main() { int x; scanf("%d",&x); if(x<=155) printf("low"); else if(x<176) printf("moderate"); else printf("high"); return 0; } 
Problem1352:#include void min(int array[], int* p, int n) { *p=array[0]; for (int i = 0; i < n; i++) { if (*p > array[i]) *p = array[i]; } } int main() { int array[10]; int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &array[i]); int p; min(array, &p, n); printf("%d\n", p); return 0; } 
Problem1357:#include int main() { int m,i,sum=0; scanf("%d",&m); for(i=1;i<=m;i++) if(i%3==0&&i%5!=0) sum=sum+i; printf("%d",sum); return 0; }
Problem1366:#include int main() { int a[100],x,n,i,j,k; while(scanf("%d",&n)!=EOF) { for(i=0;ix) j++; } if(k==0) printf("No find 0\n"); else printf("Find %d\n",j); scanf("%d",&n); } return 0; }
Problem1379:#include #include #include #include #include using namespace std; int miniElement(int array[], int n) { int small=array[0]; for (int i = 0; i < n; i++) if (small > array[i]) small = array[i]; return small; } double miniElement(double array[], int n) { double small = array[0]; for (int i = 0; i < n; i++) if (small > array[i]) small = array[i]; return small; } int main() { int n; int a[20]; double b[20]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << miniElement(a, n) << endl; cin >> n; for (int i = 0; i < n; i++) cin >> b[i]; cout << miniElement(b, n) << endl; return 0; }
Problem1380:#include #include #include #include #include using namespace std; void del(string& a, string& b) { int p; p = a.find(b); while (p != 1) { int len = b.length(); a.erase(p, len); p = a.find(b); } } int main() { string str; string substr; int t; cin >> t; while(t) { cin >> str >> substr; del(str, substr); cout << str << endl; } return 0; }
Problem1381:#include #include #include #include #include using namespace std; bool PD(string mid) { int len = mid.length(); for (int i = 0; i < len; i++) if (islower(mid.at(i))) mid.at(i) = 32; string s = mid; int flag = 0; for (int i = 0; i < len; i++) if (s.at(len  1  i) == mid.at(i)) flag++; if (flag == len) return true; else return false; } int main() { string str; getline(cin, str); if (PD(str)) cout << "true" << endl; else cout << "false" << endl; return 0; }
Problem1382:#include #include #include #include #include using namespace std; void zgq(int s[],int& a, int& b,int& n) { int t; for(int i=0;i s[j + 1]) { t = s[j]; s[j] = s[j + 1]; s[j + 1] = t; } a = s[n  1]; b = s[n  2]; } int main() { int a[20]; int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int max1, max2; zgq(a, max1, max2, n); cout << max1 << ' ' << max2 << endl; return 0; }
Problem1383:#include #include #include #include #include using namespace std; class current_date { public: current_date(int dayVal,int monthVal, int yearVal):day(dayVal),month(monthVal),year(yearVal) { } void assign_data(int dayVal, int monthVal, int yearVal) { day = dayVal; month = monthVal; year = yearVal; } void display_data() { cout << month << "/" << day << "/" << year << endl; } bool RN() { if (year % 4 == 0 && year % 400 == 0) return true; else return false; } void increment_date() { day++; if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { if (day > 31) { day = 1; month++; if (month > 12) { year++; month = 1; } } } else if (month == 2) { if (RN()) { if (day > 29) { day = 1; month++; } } else if (day > 28) { day = 1; month++; } } else if (day > 30) { day = 1; month++; } } private: int day; int month; int year; }; int main() { int i, day, month, year; current_date mydate(10, 1, 2013); mydate.display_data(); cin >> day >> month >> year; mydate.assign_data(day, month, year); for (i = 1; i <= 10; i++) { mydate.increment_date(); } mydate.display_data(); return 0; }
Problem1384:#include #include #include #include #include using namespace std; class Complex { public: Complex() { real = 1.0; imaginary = 1.0; } Complex(double a, double b) :real(a),imaginary(b) { } double calculate_magnitude() { return sqrt(real * real + imaginary * imaginary); } private: double real; double imaginary; }; int main() { double real, imaginary; Complex one; double a=one.calculate_magnitude(); cin >> real >> imaginary; Complex tow(real, imaginary); double b=tow.calculate_magnitude(); cout << fixed << setprecision(2) << a << ' ' << b; return 0; }
Problem1385:#include #include #include #include #include using namespace std; class JX { public: JX() { len = 1.0; wid = 1.0; } JX(double a, double b) :len(a), wid(b) { } double calculate_area() { return len * wid; } private: double len; double wid; }; int main() { JX one; double a, b; cin >> a >> b; JX two(a, b); cout << fixed << setprecision(2) << one.calculate_area() << ' ' << two.calculate_area(); return 0; }
Problem1386:#include #include #include #include #include using namespace std; class robot { public: // Constructor with default arguments and constructor list. robot(float x = 0, float y = 0) : x_coord(x), y_coord(y) {} // Inspector function to display the robot's position. void display_position() { cout << "(" << x_coord << "," << y_coord << ")" << endl; } void left(float t) { x_coord = t; } void right(float t) { x_coord += t; } void back(float t) { y_coord += t; } void forward(float t) { y_coord = t; } void return_to_base() { x_coord = 0; y_coord = 0; } void gotoDest(float a, float b) { x_coord = a; y_coord = b; } private: float x_coord, y_coord; }; int main() { double destX, destY; robot r2d2(10.0, 8.1); // Constructor sets the initial // position. r2d2.left(1.3); // Move robot left 1.3 cms. // New position is (8.7,8.1) r2d2.display_position(); r2d2.back(4.21); // Move robot back 4.21 cms. // New position is (8.7,12.31) r2d2.display_position(); r2d2.right(3.1); // Move robot right 3.1 cms. // New position is (11.8,12.31) r2d2.display_position(); r2d2.return_to_base(); // Sets the position to (0,0). r2d2.back(0.6); r2d2.forward(0.3); // Move robot forward 3.1 cms. // New position is (0,0.3). r2d2.display_position(); cin >> destX >> destY; r2d2.gotoDest(destX, destY); r2d2.display_position(); return 0; }
Problem1387:#include #include #include #include #include using namespace std; class Box { public: Box(int a,int b,int c):x(a),y(b),z(c) { } int volumn() { return x * y * z; } int area() { return 2 * x * y + 2 * x * z + 2 * y * z; } private: int x; int y; int z; }; int main() { int a, b, c; cin >> a >> b >> c; Box t(a, b, c); cout << t.volumn() << ' ' << t.area(); return 0; }
Problem1389:#include #include #include #include #include using namespace std; class student { public: student(string m, string n, int i, int j) :num(m), name(n), a(i), b(j) { } void display() { cout << num << ' ' << name << ' ' << a << ' ' << b << ' ' << a + b; } private: string num; string name; int a, b; }; int main() { string a, b; int c, d; cin >> a >> b >> c >> d; student t(a, b, c, d); t.display(); return 0; }
Problem1390:#include #include #include #include #include using namespace std; class matrix { public: matrix(int m, int n) :row(m), col(n) { p = new int* [m]; for (int i = 0; i < m; i++) { p[i] = new int[n]; } int flag = 1; for(int i=0;i> rowNum >> colNum; matrix mat(rowNum, colNum); cout << mat.at(4) << ' ' << mat.at(3, 4) << ' ' << mat.sum(); }
Problem1391:#include #include #include #include #include using namespace std; class matrix { public: matrix(int m, int n) { row = m; col = n; p = new int* [row]; for (int i = 0; i < row; i++) p[i] = new int[col]; for (int i = 0; i < row; i++) { int k = 1; for (int j = 0; j < col; j++) { p[i][j] = (k++) + i * 10; } } } int at(int i) { int m = i1 ; return p[m % row][m / row]; } int at(int i, int j) { return p[i  1][j  1]; } int sum(int m) { int all = 0; for (int i = 0; i < m; i++) for (int j = 0; j < col; j++) all += p[i][j]; return all; } private: int row; int col; int** p; }; int main() { int rowNum, colNum; cin >> rowNum >> colNum; matrix mat(rowNum, colNum); cout << mat.at(5) << ' ' << mat.at(4, 5) << ' ' << mat.sum(3); }
Problem1392:#include #include #include #include #include using namespace std; class date { public: date(int a,int b,int c):year(a),month(b),day(c) {} bool PD() { if (year % 4 == 0 || (year % 400 == 0&&year %100!=0)) return true; else return false; } int orderOfYear() { int all = day; for (int i = 1; i < month; i++) { if (i == 1 || i == 3 || i == 5 ||i == 7 || i == 8 || i == 10) all += 31; else if (i == 2) { if (PD()) all += 29; else all += 28; } else all += 30; } return all; } private: int day; int month; int year; }; int main() { int a, b, c; cin >> a >> b >> c; date t(a, b, c); cout << t.orderOfYear() << endl; return 0; }
Problem1393:#include #include #include #include #include using namespace std; class worker { public: worker(string a, string b, int c, int d) :num(a), name(b), money(c), x(d) { } int sum() { return money + x; } void display() { cout << num << ' ' << name << ' ' << money << ' ' << x << ' ' << sum(); } private: string num; string name; int money; int x; }; int main() { string a, b; int c, d; cin >> a >> b >> c >> d; worker t(a, b, c, d); t.display(); return 0; }
Problem1394:#include #include #include #include #include using namespace std; class student { public: student(string n, string m, int i, int j, int k) :num(n), name(m), a(i), b(j), c(k) { } void sum() { sumScore = a + b + c; } void display() { cout << num << ' ' << name << ' ' << a << ' ' << b << ' ' << c << ' ' << sumScore; } private: string num; string name; int a, b, c; int sumScore; }; int main() { string a, b; int c, d,e; cin >> a >> b >> c >>d >> e; student t(a, b, c, d, e); t.sum(); t.display(); return 0; }
Problem1395:#include #include #include #include #include #define PI 3.14 using namespace std; class cylinder { public: cylinder() { r = 1; h = 1; } cylinder(int m, int n) :r(m), h(n) { } double volume() { return PI * r * r * h; } double area() { return PI * r * r * 2 + 2 * PI * r * h; } private: double r; double h; }; int main() { double radius, height; cin >> radius >> height; cylinder cylinder1, cylinder2(radius, height); cout << fixed << setprecision(2) << cylinder1.volume() << ' ' << cylinder1.area() << ' ' << cylinder2.volume() << ' ' << cylinder2.area(); return 0; }
Problem1396:#include #include #include #include #include using namespace std; class teacher { public: teacher() { cin >> num >> name >> address >> x >> y; } teacher(string a, string b, string c) :num(a), name(b), address(c) { x = 0; y = 0; } void display() { cout << num << ' ' << name << ' ' << address << ' ' << x << ' ' << y << endl; } private: string num; string name; string address; int x; int y; }; int main() { teacher tea1; tea1.display(); string teaNo, teaName, address; cin >> teaNo >> teaName >> address; teacher tea2(teaNo, teaName, address); tea2.display(); return 0; }
Problem1397:#include #include #include using namespace std; class complex { public: complex(); complex(double real1,double imag2); void display(); void input(); double magnitude(); private: double real; double imag; }; complex::complex():real(1.0),imag(1.0) { } complex::complex(double real1,double imag2):real(real1),imag(imag2) { } void complex::display() { if(imag==0) cout<>a>>b; real=a; imag=b; } double complex::magnitude() { return(sqrt(real*real+imag*imag)); } int main() { complex val1,val2,val3(1.5,2.8); val1.input(); val1.display(); cout<<" "< #include #include #include #include using namespace std; class cube { public: cube() { x = 1; y = 1; z = 1; } cube(int a) :x(a) { y = 1; z = 1; } cube(int a, int b) :x(a), y(b) { z = 1; } cube(int a, int b, int c) :x(a), y(b), z(c) { } void input() { cin >> x >> y >> z; } int volume() { return x * y * z; } int area() { return 2 * x * y + 2 * x * z + 2 * y * z; } void display() { cout << x << ',' << y << ',' << z << ','; } private: int x; int y; int z; }; int main() { cube c1, c2, c3(2), c4(2, 3), c5(2, 3, 4); c1.input(); c1.display(); cout << c1.volume() << "," << c1.area() << endl; c2.display(); cout << c2.volume() << "," << c2.area() << endl; c3.display(); cout << c3.volume() << "," << c3.area() << endl; c4.display(); cout << c4.volume() << "," << c4.area() << endl; c5.display(); cout << c5.volume() << "," << c5.area() << endl; return 0; }
Problem1399:#include #include #include #include #include using namespace std; class student { public: student() { num = ""; name = ""; score = 0; } void input() { cin >> num >> name >> score; } void display() { cout << num << ' ' << name << ' ' << score << endl; } private: string num; string name; int score; }; int main() { int n; cin >> n; student* p; p = new student[n]; for (int i = 0; i < n; i++) p[i].input(); for (int i = 0; i < n; i++) p[i].display(); delete[] p; return 0; }
Problem1400:#include #include #include #include #include using namespace std; class matrix { public: matrix(int m, int n) :row(m), col(n) { p = new int* [m]; for (int i = 0; i < m; i++) { p[i] = new int[n]; } int flag = 1; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) { p[i][j] = flag++; } } int at(int i) { int t = i  1; return p[t / col][t % col]; } int at(int i, int j) { return p[i  1][j  1]; } int sum() { int all = 0; for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) { all += p[i][j]; } return all; } ~matrix() { for (int i = 0; i < row; i++) delete[] p[i]; delete[] p; } private: int row; int col; int** p; }; int main() { int rowNum, colNum; cin >> rowNum >> colNum; matrix mat(rowNum, colNum); cout << mat.at(4) << ' ' << mat.at(3, 4) << ' ' << mat.sum(); }
Problem1401:#include #include #include #include #include using namespace std; class Complex { public: Complex() { real = 1.0; imaginary = 1.0; } Complex(double a, double b) :real(a), imaginary(b) { } Complex operator+(Complex& t) { Complex temp; temp.real = real + t.real; temp.imaginary = imaginary + t.imaginary; return temp; } Complex operator(Complex& t) { Complex temp; temp.real = real  t.real; temp.imaginary = imaginary  t.imaginary; return temp; } void display() { cout << fixed << setprecision(2); if (imaginary > 0) cout << real << '+' << imaginary << 'i' << endl; else if (imaginary == 0) cout << real << endl; else cout << real << imaginary << 'i' << endl; } private: double real; double imaginary; }; int main() { double m, n; cin >> m >> n; Complex a(m, n); cin >> m >> n; Complex b(m, n); Complex c, d; c = a + b; d = a  b; c.display(); d.display(); return 0; }
Problem1402: #include #include #include #include #include using namespace std; class student { public: student(string a, string b) :stuNum(a), stuName(b) { x = 0; y = 0; z = 0; } student(string a, string b, int c, int d, int e) :stuNum(a), stuName(b), x(c), y(d), z(e) { } void sumfun() { sumscore = x + y + z; } void inputscore() { cin >> x >> y >> z; } void display() { cout << stuNum << ' ' << stuName << ' ' << x << ' ' << y << ' ' << z << ' ' << sumscore << endl; } private: string stuNum; string stuName; int x, y, z; int sumscore; }; int main() { student st1("111", "John"), st2("222", "Mike", 67, 89, 92); st1.inputscore(); st1.sumfun(); st2.sumfun(); st1.display(); st2.display(); return 0; }
Problem1403:#include #include #include #include #include using namespace std; class teacher { public: teacher(string a,string b):jobNO(a),Name(b) { base_pay = 0; allowance = 0; insurance = 0; all_salary = 0; real_salary = 0; } teacher(string a,string b,double c,double d,double e):jobNO(a),Name(b),base_pay(c),allowance(d),insurance(e) { all_salary = 0; real_salary = 0; } void salary() { all_salary = base_pay + allowance; real_salary = all_salary  insurance; } void display() { cout << jobNO << ' ' << Name << ' ' << base_pay << ' ' << allowance << ' ' << insurance << ' ' << all_salary << ' ' << real_salary << endl; } void input() { cin >> base_pay >> allowance >> insurance; } private: string jobNO; string Name; double base_pay; double allowance; double insurance; double all_salary; double real_salary; }; int main() { teacher t1("111", "Mary"), t2("222", "Alex", 4256.78, 1234.56, 895.17); t1.input(); t1.salary(); t2.salary(); t1.display(); t2.display(); return 0; } 
Problem1418:#include #include using namespace std; class complex { public: complex(); complex operator+(complex& t); complex operator(complex& t); bool operator==(complex& t); bool operator!=(complex& t); bool operator>(complex& t); bool operator<(complex& t); void setReal(double realVal); void setImag(double imagVal); double getReal() { return real; } double getImag() { return imaginary; } private: double real; double imaginary; }; complex::complex() {} complex complex::operator+(complex& t) { complex temp; temp.real= real + t.real; temp.imaginary = imaginary + t.imaginary; return temp; } complex complex::complex::operator(complex& t) { complex temp; temp.real = real  t.real; temp.imaginary = imaginary  t.imaginary; return temp; } bool complex::operator==(complex& t) { if(real==t.real&&imaginary==t.imaginary) return true; else return false; } bool complex::operator!=(complex& t) { if ((*this) == t) return false; else return true; } bool complex::operator>(complex& t) { if (imaginary != 0 && t.imaginary != 0) if ((real * real + imaginary * imaginary) > (t.real * t.real + t.imaginary * t.imaginary)) return true; else return false; else if (real > t.real) return true; else return false; } bool complex::operator<(complex& t) { if ((*this) > t) return false; else return true; } void complex::setReal(double realVal) { real = realVal; } void complex::setImag(double imagVal) { imaginary = imagVal; } istream& operator>>(istream& is, complex& t) { double a,b; char ch; is >> a >> ch; if (ch == '+') is >> b >> ch; if (ch == '') is >> b >> ch, b = b; t.setReal(a); t.setImag(b); return is; } ostream& operator<<(ostream& oc, complex& t) { double a = t.getReal(), b = t.getImag(); oc << fixed << setprecision(2); oc << a; if (b != 0) if(b>0) oc << '+' << b << 'i' << endl; else oc << b << 'i' << endl; return oc; } int main() { complex c1, c2, c3, c4, c5; cin >> c1 >> c2; c3 = c1 + c2; c4 = c1  c2; if (c3 != c4) { if (c3 < c4) { cout << "c3 is less than c4"; c5 = c4  c3; } if (c3 > c4) { cout << "c3 is greater than c4"; c5 = c3  c4; } } if (c3 == c4) { cout << "c3 and c4 are equal"; c5 = c4; } cout << endl; cout << c5; return 0; }
Problem1419:#include #include #include #include #include using namespace std; class fraction { public: fraction() { fenzi = 0; fenmu = 1; } fraction(int m,int n):fenzi(m),fenmu(n) {} int yueshu(int m, int n) { int t; do { t = m % n; m = n; n = t; } while (t != 0); return m; } int GPS(int m,int n) { return m * n / yueshu(m,n); } fraction operator+(fraction& t) { int m = GPS(fenmu, t.fenmu); int a = m / fenmu; int b = m / t.fenmu; fraction temp; temp.fenzi = a * fenzi + b * t.fenzi; temp.fenmu = m; int n = yueshu(temp.fenzi, temp.fenmu); temp.fenzi /= n; temp.fenmu /= n; return temp; } fraction operator(fraction& t) { int m = GPS(fenmu, t.fenmu); int a = m / fenmu; int b = m / t.fenmu; fraction temp; temp.fenzi = a * fenzi  b * t.fenzi; temp.fenmu = m; int n = yueshu(temp.fenzi, temp.fenmu); temp.fenzi /= n; temp.fenmu /= n; return temp; } fraction operator*(fraction& t) { fraction temp; temp.fenzi = fenzi * t.fenzi; temp.fenmu = fenmu * t.fenmu; int n = yueshu(temp.fenzi, temp.fenmu); temp.fenzi /= n; temp.fenmu /= n; return temp; } fraction operator/(fraction& t) { fraction temp; temp.fenzi = fenzi * t.fenmu; temp.fenmu = fenmu * t.fenzi; int n = yueshu(temp.fenzi, temp.fenmu); temp.fenzi /= n; temp.fenmu /= n; return temp; } void input() { cin >> fenzi >> fenmu; } void output() { if (fenmu == 1 || fenzi == 0) cout << fenzi< void change(double *p1,double *p2); int main() { double a,b; scanf("%lf%lf",&a,&b); change(&a,&b); printf("%.2lf %.2lf",a,b); return 0; } void change(double *p1,double *p2) { *p1=*p1/2; *p2=*p2*2; } 
Problem1421:#include int next(int *p1,int *p2); int main() { int a,b; scanf("%d%d",&a,&b); next(&a,&b); printf("%d %d",a,b); return 0; } int next(int *p1,int *p2) { int t; if(*p1>*p2) { t=*p1; *p1=*p2; *p2=t; } } 
Problem1421:#include void next(int *p1,int *p2); int main() { int a,b; scanf("%d%d",&a,&b); next(&a,&b); return 0; } void next(int *p1,int *p2) { int *p; if(*p1>*p2) { p=p1; p1=p2; p2=p; } printf("%d %d",*p1,*p2); } 
Problem1421:#include void next(int *p1,int *p2); int main() { int a,b; scanf("%d%d",&a,&b); next(&a,&b); return 0; } void next(int *p1,int *p2) { int *t; if(*p1>*p2) { t=p1; p1=p2; p2=t; } printf("%d %d",*p1,*p2); } 
Problem1422:#include int sum(int a,int *p1,int *p2); int main() { int a,m,n; scanf("%d",&a); sum(a,&m,&n); printf("%d %d",m,n); return 0; } int sum(int a,int *p1,int *p2) { int cou=0; *p1=0; *p2=0; while(a!=0) { cou++; if((cou%2)==0) *p2=*p2+a%10; else *p1=*p1+a%10; a=a/10; } } 
Problem1422:#include void sum(int x,int *p,int *q) { int d,i=0; while(x!=0) { i++; d=x%10; x/=10; if(i%2==1) *q+=d; else *p+=d; } } int main() { int y,*p1,*q1,asum1=0,asum2=0; p1=&asum1; q1=&asum2; scanf("%d",&y); sum(y,&asum1,&asum2); printf("%d %d",*q1,*p1); return 0; } 
Problem1424:#include using namespace std; class point { public: point operator+(point& t) { point temp; temp.a = a + t.a; temp.b = b + t.b; return temp; } point operator(point& t) { point temp; temp.a = a  t.a; temp.b = b  t.b; return temp; } bool operator==(point& t) { if (a == t.a && b == t.b) return true; else return false; } bool operator!=(point& t) { if (*this == t) return false; else return true; } void set(int& m, int& n) { a = m; b = n; } void get(int& m, int& n) { m = a; n = b; } private: int a; int b; }; istream& operator>>(istream& in, point& t) { int m, n; in >> m >> n; t.set(m, n); return in; } ostream& operator<<(ostream& os, point& t) { int m, n; t.get(m, n); os << '(' << m << ',' << n << ')' << endl; return os; } int main() { point x, y, z1, z2; cin >> x >> y; z1 = x + y; z2 = x  y; cout << z1 << z2; if (x == y) cout << "x==y" << endl; else cout << "x!=y" << endl; if (z1 != z2) cout << "z1!=z2" << endl; else cout << "z1==z2" << endl; return 0; }
Problem1425:#include using namespace std; class intArray { public: intArray(int num) :num(num) { p = new int[num]; for (int i = 0; i < num; i++) cin >> p[i]; } ~intArray() { delete[] p; } int operator()(int index) { return p[index]; } int getnum() { return num; } private: int num; int* p; }; ostream& operator<<(ostream& os, intArray& t) { int n = t.getnum(); for (int i = 0; i < n  1; i++) os << t(i) << ' '; os << t(n  1) ; return os; } int main() { int i, num; cin >> num; intArray arr(num); for (i = 0; i < num; i++) cout << arr(i) << " "; cout << endl; cout << arr; return 0; }
Problem1426:#include using namespace std; class charArray { public: charArray(int num) :num(num) { p = new char[num]; for (int i = 0; i < num; i++) cin >> p[i]; } ~charArray() { delete[] p; } char operator[](int index) { return p[index]; } int getnum() { return num; } private: int num; char* p; }; ostream& operator<<(ostream& os, charArray& t) { int n = t.getnum(); for (int i = 0; i < n  1; i++) os << t[i] << ' '; os << t[n1] ; return os; } int main() { int i, num; cin >> num; charArray arr(num); for (i = 0; i < num; i++) cout << arr[i] << " "; cout << endl; cout << arr; return 0; }
Problem1439:#include using namespace std; class fraction { public: fraction(int a = 0, int b = 1); void print(); void reduction(); void common_denominator(fraction& t); fraction operator+(fraction& t); fraction operator(fraction& t); fraction operator*(fraction& t); fraction operator/(fraction& t); private: int fenzi; int fenmu; }; fraction::fraction(int a , int b ) { fenzi = a; fenmu = b; } void fraction::print() { reduction(); if (fenmu == 1) cout << fenzi; else cout << fenzi << "/" << fenmu; } void fraction::reduction() { int t,a,b; a = fenzi; b = fenmu; do { t = a % b; a = b; b = t; } while (t != 0); fenzi = fenzi / a; fenmu = fenmu / a; } void fraction::common_denominator(fraction& t) { int temp, a, b; a = t.fenmu; b = fenmu; do { temp = a % b; a = b; b = temp; } while (temp != 0); int maxt; maxt = fenmu * t.fenmu / a; int m= maxt / fenmu, n= maxt / t.fenmu; fenmu = maxt; fenzi = m* fenzi; t.fenmu = maxt; t.fenzi = n* t.fenzi; } fraction fraction::operator+(fraction& t) { (*this).common_denominator(t); fraction temp; temp.fenmu = fenmu; temp.fenzi = fenzi + t.fenzi; temp.reduction(); return temp; } fraction fraction::operator(fraction& t) { (*this).common_denominator(t); fraction temp; temp.fenmu = fenmu; temp.fenzi = fenzi  t.fenzi; temp.reduction(); return temp; } fraction fraction::operator*(fraction& t) { fraction temp; temp.fenzi = fenzi * t.fenzi; temp.fenmu = fenmu * t.fenmu; temp.reduction(); return temp; } fraction fraction::operator/(fraction& t) { fraction temp; temp.fenzi = fenzi * t.fenmu; temp.fenmu = fenmu * t.fenzi; temp.reduction(); return temp; } int main() { int a, b; cin >> a >> b; fraction x1, x2(2), x3(a, b), y1(2, 3), y2(3, 8), z1, z2, z3, z4; x1.print(); cout << endl; x2.print(); cout << endl; x3.print(); cout << endl; y2.print(); cout << endl; z1 = x3 + y1; z1.print(); cout << endl; z2 = x3  y1; z2.print(); cout << endl; z3 = x3 * y2; z3.print(); cout << endl; z4 = x3 / y2; z4.print(); return 0; }
Problem1440:#include using namespace std; class figure { public: figure(double w, double h); protected: double height; double width; }; figure::figure(double w, double h):height(h),width(w) {} class rectangle:public figure { public: rectangle(double w, double h); void display(); double area(); }; rectangle::rectangle(double w, double h):figure(w,h) {} void rectangle::display() { cout << "I am a rectangle. The value of width is " << width << ", the height is " << height; } double rectangle::area() { return height * width; } class triangle :public figure { public: triangle(double w, double h); void display(); double area(); }; triangle::triangle(double w, double h) :figure(w,h) {} void triangle::display() { cout << "I am a triangle. The value of width is " << width << ", the height is " << height; } double triangle::area() { return 0.5 * height * width; } int main() { double width, height; cin >> width >> height; triangle tri(width, height); rectangle rect(width, height); tri.display(); cout << ". The area is " << tri.area() << endl; rect.display(); cout << ". The area is " << rect.area() << endl; return 0; }
Problem1441:#include #include using namespace std; class Animal { public: virtual void cry() = 0; }; class Mouse:public Animal { public: Mouse(string a):name(a) {} void cry() { cout << "I am a mouse, my name is " << name << ", zhizhi." << endl; } private: string name; }; class Cat :public Animal { public: Cat(string a) :name(a) {} void cry() { cout << "I am a cat, my name is " << name << ", miaomiao." << endl; } private: string name; }; class Dog :public Animal { public: Dog(string a) :name(a) {} void cry() { cout << "I am a dog, my name is " << name << ", wangwang." << endl; } private: string name; }; int main() { Animal* p; string name; cin >> name; Mouse m1(name); p = &m1; p>cry(); cin >> name; Cat c1(name); p = &c1; p>cry(); cin >> name; Dog d1(name); p = &d1; p>cry(); }
Problem1454:#include #include using namespace std; template struct LinkNode { T data; LinkNode* link; LinkNode() { link = NULL; } LinkNode(T x) { data = x; link = NULL; } }; template class List { public: List(); ~List(); void output(); void inputRear(T num); LinkNode* get_first() { return first; } private: LinkNode* first; LinkNode* last; }; template List::List() { first = new LinkNode; last = first; } template List::~List() { } template void List::inputRear(T num) { LinkNode* newnode; newnode = new LinkNode(num); last>link = newnode; last = newnode; } template void List::output() { LinkNode* p = first>link; if (p == NULL) cout << "空表!\n"; else { while (p>link != NULL) { cout << p>data << ">"; p = p>link; } cout << p>data << endl; } } template void Max(List& t, int& max) { LinkNode* p; p = t.get_first(); p = p>link; max = p>data; while (p != NULL) { if (p>data > max) max = p>data; p = p>link; } } template int cont(List& t,int& m) { int count = 0; LinkNode* p; p = t.get_first(); p = p>link; while (p != NULL) { if (p>data == m) count++; p = p>link; } return count; } int main() { List A; int num; while (cin >> num && num != 1) A.inputRear(num); int m,count; cin >> m; count = cont(A, m); A.output(); cout << count << endl; return 0; } 
Problem1455:#include #include using namespace std; template struct LinkNode { T data; LinkNode* link; LinkNode() { link = NULL; } LinkNode(T x) { data = x; link = NULL; } }; template class List { public: List(); ~List(); void output(); void inputRear(T num); LinkNode* get_first() { return first; } private: LinkNode* first; LinkNode* last; }; template List::List() { first = new LinkNode; last = first; } template List::~List() { } template void List::inputRear(T num) { LinkNode* newnode; newnode = new LinkNode(num); last>link = newnode; last = newnode; } template void List::output() { LinkNode* p = first>link; if (p == NULL) cout << "空表!\n"; else { while (p>link != NULL) { cout << p>data << ">"; p = p>link; } cout << p>data << endl; } } template void Max(List& t, int& max) { LinkNode* p; p = t.get_first(); p = p>link; max = p>data; while (p != NULL) { if (p>data > max) max = p>data; p = p>link; } } int main() { List A; int num; while (cin >> num && num != 1) A.inputRear(num); int max; Max(A, max); A.output(); cout << max << endl; return 0; } 
Problem1458:#include #include #includeusing namespace std; class Stack { public: Stack() { maxsize = 100; top = 1; data = new char[maxsize]; } bool push(const char& x) { if (top == maxsize  1) return false; data[++top] = x; return true; } bool pop(char x) { if (top == 1) return false; data[top] = x; return true; } bool get_top(char& x) { if (top == 1) return false; else { x = data[top]; return true; } } bool stack_empty() { if (top == 1) return true; else return false; } private: int top; int maxsize; char* data; }; bool judge_dquo(Stack t) { string str; getline(cin, str); int m = str.length(); for(int i=0;i < m;i++) { if (str[i] == '(' || str[i] == ')' || str[i] == '[' || str[i] == ']' || str[i] == '{' || str[i] == '}') { if (t.stack_empty()) { if (str[i] == ')' || str[i] == ']' || str[i] == '}') { return false; } else { t.push(str[i]); } } else { char temp='\0'; t.get_top(temp); if (temp == '(' && str[i] == ')' || temp == '[' && str[i] == ']' || temp == '{' && str[i] == '}') { t.pop(temp); } else { t.push(str[i]); } } } } return t.stack_empty(); } int main() { Stack t; if (judge_dquo(t)) cout << "success" << endl; else cout << "failure" << endl; return 0; } 
Problem1469:#include #include int s(int x,int y); int main() { int m,n; while(scanf("%d%d",&m,&n)!=EOF) printf("%d\n",s(m,n)); return 0; } int s(int x,int y) { int t,mid; if(x>y){t=x;x=y;y=t;} do{ mid=y%x; y=x; x=mid; }while(x!=0); return y; } 
Problem1469:#include int s(int x,int y); int main() { int m,n; while(scanf("%d%d",&m,&n)!=EOF) printf("%d\n", s(m,n)) ; return 0; } int s(int x,int y) { int t,mid; if(x>y){t=x;x=y;y=t;} do{ mid=y%x; y=x; x=mid; }while(x!=0); return y; } 
Problem1471:#include void s(char *p); int main() { char a[100]; while(gets(a)!=NULL) { s(a); puts(a); } return 0; } void s(char *p) { int i; for(i=0;*(p+i);i++) if((*(p+i)>='a'&&*(p+i)<='z')||(*(p+i)>='A'&&*(p+i)<='Z')) continue; else *(p+i)=' '; } 
Problem1497:#include int main() { int t,m,a[100],max,mid,i; scanf("%d",&t); while(t) { scanf("%d",&m); for(i=0;i max) max=a[i]; for(i=0;imid) mid=a[i]; printf("%d %d\n",max,mid); } return 0; }
Problem1499:#includeint main() { int T,i,n,a[100],max,min; scanf("%d",&T); while(T) { scanf("%d",&n); for(i=0;i max) max=a[i]; if(a[i]#include using namespace std; int main() { int a[4]; int i; for(i=0;i<=3;i++) cin >> a[i]; for(i=0;i<=3;i++) { cout << a[3i]; if(i!=3) cout.put(' '); } return 0; } 
Problem1522:#include #includeusing namespace std; int main() { int a ; cin >> a ; cout << a/24/7 << ' ' << a/24%7 << ' ' << a%24 ; return 0; } 
Problem1523:#include #includeusing namespace std; int main() { float a,b,c; cin >> a >> b >> c; cout << fixed << setprecision(3); cout << a+b+c << ' ' << (a+b+c)/3; return 0; } 
Problem1534:#include #include #include using namespace std; int main() { string name[3], mid; for (int i = 0;i < 3 ; i++) getline(cin, name[i]); for (int i = 0;i <2; i++) { for(int j=i+1;j< 3 ; j++) if (name[i] > name[j]) { mid = name[i]; name[i] = name[j]; name[j] = mid; } } for (int i = 0; i < 3 ; i++) cout << name[i] << endl; return 0; }
Problem1534:#include #include #include using namespace std; int main() { string name[3], mid; for (int i = 0;i < 3 ; i++) getline(cin, name[i]); for (int i = 0;i <2; i++) { for(int j=i+1;j< 3 ; j++) if (name[i] > name[j]) { mid = name[i]; name[i] = name[j]; name[j] = mid; } } for (int i = 0; i < 3 ; i++) cout << name[i] << endl; return 0;}
Problem1535:#include #include #include using namespace std; int main() { string a; getline(cin, a); int len = a.length(); int flag=0; a += ' '; int mid=0; for (int i = 0; i < len; i++) { if (isalpha(a.at(i)) && !isalpha(a.at(i + 1))) flag++; if (!isalpha(a.at(i))) mid++; } double PJ; a.erase(len); int b = a.length(); PJ = ( static_cast (len)  mid ) / static_cast(flag); cout << fixed << setprecision(1)<< PJ << endl; return 0; }
Problem1536:#include#include #include using namespace std; int main() { string a; getline(cin, a); int len = a.length(); for (int i = 0; i < len; i++) if (!isdigit(a.at(i))) { cout << "error" << endl; exit(0); } char array[100]; a.copy(array, len); array[len] = '\0'; int math; math = atoi(array); cout << math + 1 << endl; return 0; }
Problem1537:#include #include #include using namespace std; int main() { string a, b; getline(cin, a); getline(cin, b); int len = a.length(); char ch; for (int i = 0; i < len; i++) { ch = a.at(i); int p = b.find(ch); if (p == 1) { cout << "no" << endl; exit(0); } b.erase(p, 1); } int end = b.length(); if(end!=0) { cout << "no" << endl; exit(0); } cout << "yes" << endl; return 0; }
Problem1538:#include using namespace std; void find(int s[], int& p,int& m,int& n) { p = 1; for (int i = 0; i < n; i++) if (s[i] == m) p = i; } int main() { int s[20]; int n; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; int p; int m; cin >> m; find(s, p, m,n); cout << p; return 0; }
Problem1539:#include #include #include using namespace std; void sort(int a[], int m); void sort(string a[],int m); int main() { string b[10]; int m; int cou = 2; while (cou) { cin >> m; for (int i = 0; i < m; i++) { cin >> b[i]; } sort(b, m); for (int i=0; i < m1; i++) { cout << b[i] << ' '; } cout < a[j]) { mid = a[i]; a[i] = a[j]; a[j] = mid; } } void sort(string a[], int m) { int i, j; string mid; for (i = 0; i < m  1; i++) for (j = i + 1; j < m; j++) if (a[i] > a[j]) { mid = a[i]; a[i] = a[j]; a[j] = mid; } }
Problem1540:#include #include #include using namespace std; float min_f(const float a[],int n); int min_f(const int a[],int n); int main() { float array[100]; int n; int cou = 2; while (cou) { cin >> n; for (int i = 0; i < n; i++) cin >> array[i]; cout << min_f(array,n)<<' '; } return 0; } float min_f(const float a[],int n) { float min; min = a[0]; for (int i = 0; i < n; i++) if (min > a[i]) min = a[i]; return min; } int min_f(const int a[],int n) { float min; min = a[0]; for (int i = 0; i < n; i++) if (min > a[i]) min = a[i]; return min; }
Problem1541:#include #include #include using namespace std; void find_number(int a[],int& m, int& n,int cou); int main() { int array[100]; int n; cin >> n; for (int i = 0; i < n; i++) cin >> array[i]; int min1, min2; find_number(array,min1, min2,n); cout << min1 << ' ' << min2; return 0; } void find_number(int a[],int& m, int& n,int cou) { m = a[0]; int i,j=0; for (i = 0; i < cou; i++) if (m > a[i]) { m = a[i]; } int b[100]; for (i = 0; i < cou; i++) if (m != a[i]) b[j++] = a[i]; n = b[0]; for ( i = 0; i < cou1; i++) if (n > b[i]) n = b[i]; }
Problem1542:#include #include #include using namespace std; void change(string& a); int main() { string a; while (getline(cin, a)) { change(a); cout << a << endl; } } void change(string& a) { int len = a.length(); string b; b = a; for (int i = 0; i < len; i++) a.at(i)= b.at(len 1 i); }
Problem1542:#include #include #include using namespace std; string fanzhuan(string a) { int i, j, t; string b; char temp; t = a.length(); j = t  1; for (i = 0; i < t / 2; i++) { temp = a[i]; a[i] = a[t  i  1]; a[t  i  1] = temp; } return a; } int main() { string a; int i, t; while (getline(cin, a)) { cout << fanzhuan(a)<#include #include using namespace std; int MonthDays[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; class Date { public: Date(int a = 1, int b = 1, int c = 2008) :day(a), month(b), year(c) {} bool PD() { if (year % 4 == 0 || (year % 100 != 0 && year % 400 == 0)) return true; else return false; } void assign(int d, int m, int y) { if (m % 12 == 0) month = 12; else month = m % 12; if (PD() && month == 2) { if (d % 29 == 0) day = 29; else day = d % 29; } else { if (d % MonthDays[month] == 0) day = MonthDays[month]; else day = d % MonthDays[month]; } year = y; } void display() { cout << day << "/" << month << "/" << year << endl; } void increment(int n) { day += n; if (month == 2 && PD()) { if (day > 29) { day = 29; month++; } } else if (day > MonthDays[month]) { day = MonthDays[month]; month++; if (month > 12) { month %= 12; year++; } } } private: int day; int month; int year; }; int main() { Date date1, date2(1, 5, 2016), date3; int n, day, month, year; cin >> day >> month >> year; date3.assign(day, month, year); cin >> n; date1.display(); date2.display(); date3.display(); date3.increment(n); date3.display(); return 0; }
Problem1544:#include #include #include using namespace std; class rectangle { public: rectangle(); rectangle(double length,double width); void assign(double a,double b); double circumference(); double area(); void output(); private: double length; double width; }; rectangle::rectangle():length(0),width(0) {} rectangle::rectangle(double length,double width):length(length),width(width) {} void rectangle::assign(double a,double b) { if(a>b) length=a,width=b; else length=b,width=a; } double rectangle::circumference() { return(length*2+width*2); } double rectangle::area() { return(length*width); } void rectangle::output() { cout< >x>>y; c3.assign(x,y); cout<#include #include using namespace std; class Date { public: Date(int year=2008, int month=1, int day=1); void assign(int year1, int month1, int day1); void display(); bool leap_year(); void increment(int n); private: int year; int month; int day; }; Date::Date(int year, int month, int day):year(year), month(month), day(day) { } void Date::assign(int year1, int month1, int day1) { year = year1; month = month1; day = day1; } void Date::display() { cout << year << '' << month << '' << day< > year >> month >> day; date3.assign(year, month, day); date3.display(); cin >> n; date3.increment(n); date3.display(); return 0; }
Problem1555:#includeusing namespace std; int main() { int n; int* p; cin>>n; p=new int[n]; for(int i=0;i >*(p+i); cout<<"a["<using namespace std; class DT { public: DT(int m=1); void KZ(char a); void display(); private: int n; }; DT::DT(int m):n(m) {} void DT::KZ(char a) { if (a == '+' && n < 10) n++, display(); else if (a == '' && n > 1) n, display(); else if (a == 'S') while (n&&n!=0) display(); } void DT::display() { cout << "current floor:" << n << endl; } int main() { class DT dt; char s; do{ cin >> s; dt.KZ(s); } while (s != 'S'); return 0; }
Problem1559:#include using namespace std; class student { public: student(); void input(string a, int b); void display(); int get_age() { return age; } private: string name; int age; }; student::student():name(""),age(0) {} void student::input(string a, int b) { name = a; age = b; } void student::display() { cout << name << ' ' << age << endl; } void sort(student s[100],int flag) { student mid; for (int i = 0; i < flag1; i++) for(int j=i+1;j s[j].get_age()) { mid = s[i]; s[i] = s[j]; s[j] = mid; } } } int main() { student* p; int N; cin >> N; p = new student[N]; string x; int y; for (int i = 0; i < N; i++) { cin >> x >> y; p[i].input(x, y); } sort(p,N); for (int i = 0; i < N; i++) p[i].display(); return 0; }
Problem1560:#include using namespace std; int main() { int** A, ** B; int m, n; cin >> m >> n; A = new int* [m]; B = new int* [m]; for (int i = 0; i < m; i++) A[i] = new int[n]; for (int i = 0; i < m; i++) B[i] = new int[n]; for (int i=0; i < m; i++) for (int j = 0; j < n; j++) cin >> A[i][j]; for (int i=0; i < m; i++) for (int j = 0; j < n; j++) cin >> B[i][j]; for (int i=0; i < m; i++) for (int j = 0; j < n; j++) A[i][j] += B[i][j]; for (int i=0; i < m; i++) { for (int j = 0; j < n  1; j++) cout << A[i][j] << ' '; cout << A[i][n  1] << endl; } for (int i = 0; i < m; i++) { delete[]A[i]; delete[]B[i]; } delete[] A; delete[] B; return 0; }
Problem1561:#include using namespace std; class settype { public: settype(); //构造函数,默认空集,n=0, set=NULL; settype(const settype& B); //拷贝构造函数 ~settype(); //析构函数 void setdata(int* a, int num); //设值函数 void getdata(int* a) const; //读值函数 int get_n() const; // 获取集合当前元素数目 settype operator+(const settype& B) const; //重载运算符+,实现集合并运算 settype operator*(const settype& B) const; //重载运算符*,实现集合交运算 settype operator(const settype& B) const; //重载运算符,实现集合差运算 settype operator=(const settype& B); //重载运算符= private: int* set; //数组指针 int n; //元素的个数 }; settype::settype() { set = NULL; n = 0; } settype::settype(const settype& B) { n= B.n; set = new int[n]; for (int i = 0; i < n; i++) set[i] = B.set[i]; } settype::~settype() { delete[] set; } void settype::setdata(int* a, int num) { n = num; set = new int[n]; for (int i = 0; i < n; i++) set[i]=a[i]; } void settype::getdata(int* a) const { for (int i = 0; i < n; i++) a[i] = set[i]; } int settype::get_n() const { return n; } settype settype::operator+(const settype& B) const { settype temp; int* a; int num = n + B.n; for (int i = 0; i < n; i++) for (int j = 0; j < B.n; j++) if (set[i] == B.set[j]) num; a = new int[num]; for (int i = 0; i < n; i++) a[i] = set[i]; int count = n; for (int j = 0; j < B.n&&count >(istream& is, settype& t) { int* a; int num; cin >> num; a = new int[num]; for (int i = 0; i < num; i++) cin >> a[i]; t.setdata(a, num); delete[] a; return is; } ostream& operator<<(ostream& os, settype& t) { int* a; int n = t.get_n(); a = new int[n]; if (n != 0) { t.getdata(a); cout << '{'; for (int i = 0; i < n  1; i++) cout << a[i] << ','; cout << a[n  1] << '}' << endl; } else cout << "{}" << endl; delete[] a; return os; } int main() { settype A, B, C; cin >> A >> B; cout << "A=" << A; cout << "B=" << B; C = A + B; cout << "A+B=" << C; C = A * B; cout << "A*B=" << C; C = A  B; cout << "AB=" << C; return 0; }
Problem1583:#include#include using namespace std; template T largest_element(T s[],int n) { T mid=s[0]; for(int i=0;i >n; for(int i=0;i>a[i]; cout<>n; for(int i=0;i>b[i]; cout<>n; for(int i=0;i>c[i]; cout<using namespace std; template T power(T x, int y) { T mid=1; if(y==0) return 1; for(int i=0;i >a>>b; cout<>m>>b; cout<#include using namespace std; template class queue { public: queue(int num); ~queue(); bool insert(T item); // 元素入队列函数 T remove(); //元素出队列函数 private: T *data; int maxCount; //队列的最大容量 int front,rear; //队头和队尾为数组下标 }; template queue::queue(int num) { maxCount=num; data=new T[num]; front=0; rear=1; } template queue::~queue() { delete [] data; } template bool queue::insert(T item) // 元素入队列函数 { if(rearT queue ::remove() { int k=0; T* mid; T t; mid=new T[maxCount]; if(rear>=0) { t=data[front]; for(int i=1;i<=rear;i++) mid[k++]=data[i]; for(int i=0;iq( 3 ) ; q.insert( 'A' ) ; q.insert( 'B' ) ; q.insert( 'C' ) ; cout << q.remove() ; cout << q.remove() ; cout << q.remove() << endl; return 0; }
Problem1585:#include #include using namespace std; int main() { cout<<"ABC"< using namespace std; int main() { cout<<"ABC"< using namespace std; class goods { public: goods(int ID,string Name); void display(); protected: int num; string name; }; goods::goods(int ID, string Name):num(ID),name(Name) {} void goods::display() { cout <<"goodsID="<< num << ' ' <<"goodsName="<< name ; } class foods:public goods { public: foods(int ID, string Name, int days); void display(); protected: int days; }; foods::foods(int ID, string Name, int days):goods(ID,Name),days(days) {} void foods::display() { cout << "goodsID=" << num << ' ' << "goodsName=" << name<<' '<<"days="< > ID >> name; class goods goods1(ID, name); goods1.display(); cout << endl; cin >> ID >> name >> days; class foods foods1(ID, name, days); foods1.display(); cout << endl; return 0; }
Problem1591:#include#include using namespace std; template class Array { public: Array(); ~Array(); void Display(); void Sort(); private: T *data; int number_of_element; }; template Array ::Array() { cin>>number_of_element; data=new T[number_of_element]; for(int i=0;i>data[i]; } templateArray ::~Array() { delete [] data; } templatevoid Array ::Display() { for(int i=0;ivoid Array ::Sort() { T mid; for(int i=0;iint_array; Array double_array; int_array.Sort(); int_array.Display(); double_array.Sort(); double_array.Display(); return 0; }
Problem1608:#include "iostream" using namespace std; struct LinkNode { int data; LinkNode* link; }; class List { public: List() { head = new LinkNode; head>link = NULL; }List(int x) { head = new LinkNode; head>data = x; head>link = NULL; } ~List() { } bool creat(int x) { if (head == NULL) return false; LinkNode* current; current = head; LinkNode* newNode = new LinkNode; newNode>data = x; while (current != NULL) { if (current>link == NULL) { current>link = newNode; newNode>link = NULL; break; } else { current = current>link; } } return true; } bool search_k(int k, int& num) { LinkNode* left, * right; left = head; right = head; int count = 0; left = left>link; while (count < k) { right = right>link; if (right == NULL) { return false; } count++; } while (right != NULL) { if (right>link == NULL) { num = left>data; return true; } right = right>link; left = left>link; } } void min_change() { LinkNode* current = head; LinkNode* Min = head>link; LinkNode* t=head,* p; while (current>link != NULL) { p = current; current = current>link; if (current>data < Min>data) { t = p; Min = current; } if (current>link == NULL) { if (Min == head>link) { continue; } else { t>link = Min>link; Min>link = head>link; head>link = Min; } } } } void display() { LinkNode* p = head; p = p>link; while (p != NULL) { if (p>link != NULL) { cout << p>data << ">"; } else { cout << p>data << endl; } p = p>link; } } private: LinkNode* head; }; int main() { List SingleList; int num; while (cin >> num && num != 1) { SingleList.creat(num); } SingleList.display(); SingleList.min_change(); SingleList.display(); return 0; } 
Problem1609:#include "iostream" using namespace std; struct LinkNode { int data; LinkNode* link; }; class List { public: List() { head = new LinkNode; head>link = NULL; }List(int x) { head = new LinkNode; head>data = x; head>link = NULL; } ~List() { } bool creat(int x) { if (head == NULL) return false; LinkNode* current; current = head; LinkNode* newNode = new LinkNode; newNode>data = x; while (current != NULL) { if (current>link == NULL) { current>link = newNode; newNode>link = NULL; break; } else { current = current>link; } } return true; } bool search_k(int k, int& num) { LinkNode* left, * right; left = head; right = head; int count = 0; left = left>link; while (count < k) { right = right>link; if (right == NULL) { return false; } count++; } while (right != NULL) { if (right>link == NULL) { num = left>data; return true; } right = right>link; left = left>link; } } void max_change() { LinkNode* current = head; LinkNode* Max = head; while (current>link != NULL) { if ((current>link)>data > (Max>link)>data) { Max = current; } current = current>link; if (current>link == NULL) { if (Max>link == current) { continue; } else { LinkNode* t = Max>link; Max>link = t>link; current>link = t; t>link = NULL; current = current>link; } } } } void display() { LinkNode* p = head; p = p>link; while (p != NULL) { if (p>link != NULL) { cout << p>data << ">"; } else { cout << p>data << endl; } p = p>link; } } private: LinkNode* head; }; int main() { List SingleList; int num; while (cin >> num && num != 1) { SingleList.creat(num); } SingleList.max_change(); SingleList.display(); return 0; } 
Problem1611:#include using namespace std; void creat(int t[],int& n) { for (int i = 0; i < n; i++) cin >> t[i]; } void move(int t[], int i,int& n) { for (int j = i + 1; j < n1; j++) { t[j] = t[j + 1]; } n; } void delete_t(int t[], int& n) { for (int i = 0; i < n  1; ) { if (t[i] == t[i + 1]) { move(t, i, n); } else { i++; } } } void display(int t[], int& n) { cout << "{ "; for (int i = 0; i < n ; i++) cout << t[i] << " "; cout << "}" << endl; } int main() { int* t; int n; cin >> n; t = new int[n]; creat(t,n); delete_t(t,n); display(t, n); return 0; }
Problem1612:#include using namespace std; void creat(int t[],int& n) { for (int i = 0; i < n; i++) cin >> t[i]; } void move(int t[], int i,int n) { for (int j = i ; j < n1; j++) { t[j] = t[j + 1]; } t[n  1] = 0; } void delete_t(int t[], int& n) { for (int i = 0; i < n  1;i++ ) { if (t[i]==0) { move(t, i, n); } } } void display(int t[], int& n) { cout << "{ "; for (int i = 0; i < n ; i++) cout << t[i] << " "; cout << "}" << endl; } int main() { int* t; int n; cin >> n; t = new int[n]; creat(t,n); delete_t(t,n); display(t, n); return 0; }
Problem1613:#include"iostream" using namespace std; bool change_site(int x[], int n, int p); int main() { int n; cin >> n; int* array; array = new int[n]; for (int i = 0; i < n; i++) cin >> array[i]; int p; cin >> p; change_site(array, n, p); cout << "{ "; for (int i = 0; i < n ; i++) cout << array[i] << ' '; cout << "}" << endl; return 0; } bool change_site(int x[], int n, int p) { int* s; s = new int[n]; if (s == NULL) { cerr << "内存空间分配错误!"; return false; } for (int i = 0; i < n; i++) s[i] = x[i]; for (int i = 0; i < n; i++) { if (i < n  p) x[i] = x[p + i]; else x[i] = s[i  n + p]; } delete[] s; return true; }
Problem1614:#include #include using namespace std; template class SeqList { public: SeqList() { maxsize = 100; data = new T[maxsize]; } SeqList(int x) { maxsize = 100; len = x; data = new T[maxsize]; } int get_data(int i) { return data[i]; } void input() { for (int i = 0; i < len; i++) { cin >> data[i]; } } void input(int i, int x) { data[i] = x; } void input(int length) { len = length; } void output() { cout << "{ "; for (int i = 0; i < len; i++) { cout << data[i] << " "; } cout << "}" << endl; } int get_len() { return len; } private: int len; int maxsize; T* data; }; template void merge(SeqList LA, SeqList LB, SeqList & LC) { int m, n; m = LA.get_len(); n = LB.get_len(); int i = 0; int j = 0; int k = 0; while (i < m || j < n) { if (LA.get_data(i) < LB.get_data(j)&& i < m || j >= n) { LC.input(k, LA.get_data(i)); k++; i++; } else { if (LA.get_data(i) > LB.get_data(j) && j < n|| i >= m) { LC.input(k, LB.get_data(j)); k++; j++; } else { if (LA.get_data(i) == LB.get_data(j) && j < n && i < m) { LC.input(k, LA.get_data(i)); k++; i++; j++; } } } } LC.input(k); } int main() { int m; cin >> m; SeqListA(m); A.input(); cin >> m; SeqList B(m); B.input(); SeqList C; merge(A, B, C); C.output(); return 0; }
Problem1615:#include #include #include using namespace std; struct stacknode { int data; stacknode* link; stacknode() { data = 0; link = NULL; } stacknode(int x) { data = x; link = NULL; } }; class stack { public: stack() { top = NULL; } void creat(int num,int B) { while (num != 0) { push(num, B); } } bool push(int& num, int n) { stacknode* p; int temp; temp = num % n; num /= n; p = new stacknode(temp); if (p == NULL) return false; if (top == NULL) top = p; else { p>link = top; top = p; } return true; } void empty_pop() { stacknode* t; while (top != NULL) { t = top; cout << t>data; top = t>link; delete t; } } private: stacknode* top; }; int main() { int number; int X; cin >> X >> number; stack t; t.creat(number, X); t.empty_pop(); return 0; }
Problem1616:#include using namespace std; struct LinkNode { int data; LinkNode* link; LinkNode() { link = NULL; } LinkNode(int x) { data = x; link = NULL; } }; class LinkList { public: LinkList() { head = new LinkNode; } ~LinkList() { } void creat() { int num = 1; LinkNode* NewNode = NULL, * current = head; while (cin >> num && num != 1) { NewNode = new LinkNode(num); current>link = NewNode; current = NewNode; } } LinkNode* get_head() { return head; } void display() { LinkNode* p = head>link; while (p != NULL) { cout << p>data << " "; p = p>link; } cout << endl; } private: LinkNode* head; }; class Stack { public: Stack() { top = NULL; } ~Stack() { } void all_push(LinkNode* T) { top = T; LinkNode* current = T>link; while (current != NULL) { T = current; current = T>link; T>link = top; top = T; } } void all_pop(LinkNode* head) { while (top != head) { cout << top>data << " "; top = top>link; } cout << endl; } private: LinkNode* top; }; void change(LinkList& s, Stack& temp) { LinkNode* t = s.get_head(); temp.all_push(t); temp.all_pop(t); } int main() { LinkList s; s.creat(); s.display(); Stack temp; change(s, temp); return 0; }
Problem1625:#include #include #include #include using namespace std; template class StackList { public: StackList() { top = 1; } StackList(int n) { top = 1; stack_t = new T[n+1]; } ~StackList() { delete[] stack_t; } bool judege(T s[],int n) { int temp = n / 2; for (int i = 0; i < temp; i++) { stack_t[++top] = s[i]; } for (int i = n  temp; i < n; i++) { if (stack_t[top] == s[i]) { top; } else { break; } } if (top == 1&&n!=0) return true; else return false; } private: int top; T* stack_t; }; int main() { char s[101]; cin.getline(s, 101); int n = strlen(s); StackList t(n); if (t.judege(s, n)) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
Problem1626:#include #include #include #include using namespace std; template class Stack { public: Stack() { top = 1; maxsize = 100; data = new T[100]; } ~Stack() { delete[] data; } bool Push(T x) { if (top == maxsize  1) { cout << "栈溢出" << endl; return false; } data[++top] = x; return true; } bool Pop(T& x) { if (top == 1) { cout << "栈空" << endl; return false; } x = data[top]; return true; } T Get_top() { return data[top]; } bool Stack_empty() { if (top == 1) return true; else return false; } private: int top; int maxsize; T* data; }; int isp(char x) { if (x == '' || x == '+') { return 3; } else { if (x == '*' || x == '/') { return 5; } else { if (x == '(') { return 1; } else { if (x == ')') return 6; } } } } int icp(char x) { if (x == '' || x == '+') { return 2; } else { if (x == '*' || x == '/') { return 4; } else { if (x == '(') { return 6; } else { if (x == ')') return 1; } } } } void Transform(char str[200]) { Stack temp; char ch; int count = 0; cin.get(ch); while (ch != '#') { if (ch == '.' || (ch >= '0' && ch <= '9')) { str[count] = ch; count++; cin.get(ch); if(ch=='#') str[count++] = ' '; } else { if(str[count1]!=' ') str[count++] = ' '; if (temp.Stack_empty()) { temp.Push(ch); cin.get(ch); } else { char t; t = temp.Get_top(); if (icp(ch) > isp(t)) { temp.Push(ch); cin.get(ch); } else if (icp(ch) < isp(t)) { temp.Pop(t); str[count] = t; count++; } else { temp.Pop(t); cin.get(ch); } } } } while (!temp.Stack_empty()) { char t; temp.Pop(t); str[count++] = t; } str[count] = '\0'; } double Calctor(char str[200]) { double result = 0; Stack num; char t[10] = { 0 }; int count = 0; double m, n; for (int i = 0; str[i] != '\0'; i++) { if (str[i] != ' ') { if (str[i] == '.' || (str[i] >= '0' && str[i] <= '9')) { t[count++]= str[i]; } else { if (str[i] == '+') { num.Pop(m); num.Pop(n); result = n + m; num.Push(result); } if (str[i] == '') { num.Pop(m); num.Pop(n); result = n  m; num.Push(result); } if (str[i] == '*') { num.Pop(m); num.Pop(n); result = n * m; num.Push(result); } if (str[i] == '/') { num.Pop(m); num.Pop(n); result = n / m; num.Push(result); } } } else { if (strlen(t) > 0) { num.Push(atof(t)); memset(t, '\0', sizeof(t)); count = 0; } } } num.Pop(result); return result; } int main() { char str[200]; Transform(str); double t = Calctor(str); cout << fixed << setprecision(1) << t << endl; return 0; }
Problem1627:#include using namespace std; template struct TreeNode { T data; TreeNode * leftchild; TreeNode* rightchild; TreeNode() { leftchild = NULL; rightchild = NULL; } TreeNode(T x) { data = x; leftchild = NULL; rightchild = NULL; } }; templateclass Tree { public: Tree(); ~Tree(); void CreateTree(TreeNode *& t); void PreTra(TreeNode* t); void InodTra(TreeNode* t); void PosodTra(TreeNode* t); void deleTree(TreeNode* t); TreeNode* Get_root() { return root; } private: TreeNode* root; }; templateTree ::Tree() { root = NULL; } templateTree ::~Tree() { } templatevoid Tree ::CreateTree(TreeNode*& t) { T x; cin >> x; if (x == '#') { t = NULL; return; } t = new TreeNode(x); if (t == NULL) return; CreateTree(t>leftchild); CreateTree(t>rightchild); } templatevoid Tree ::PreTra(TreeNode* t) { if (t != NULL) { cout << t>data << ' '; PreTra(t>leftchild); PreTra(t>rightchild); } } templatevoid Tree ::InodTra(TreeNode* t) { if (t != NULL) { InodTra(t>leftchild); cout << t>data << ' '; InodTra(t>rightchild); } } templatevoid Tree ::PosodTra(TreeNode* t) { if (t != NULL) { PosodTra(t>leftchild); PosodTra(t>rightchild); cout << t>data << ' '; } } templatevoid Tree ::deleTree(TreeNode* t) { if (t == NULL) return; deleTree(t>leftchild); deleTree(t>rightchild); delete t; } int main() { Treetemp; TreeNode * head = temp.Get_root(); temp.CreateTree(head); temp.PreTra(head); cout << endl; temp.InodTra(head); cout << endl; temp.PosodTra(head); cout << endl; temp.deleTree(head); return 0; }
Problem1629:#includeusing namespace std; template struct TreeNode { T data; TreeNode * leftchild; TreeNode* rightchild; TreeNode() { leftchild = NULL; rightchild = NULL; } TreeNode(T x) { data = x; leftchild = NULL; rightchild = NULL; } }; templateclass Tree { public: Tree(); ~Tree(); void CreateTree(TreeNode *& t); void PreTra_inden(TreeNode* t, int n = 0); void deleTree(TreeNode* t); TreeNode* Get_root() { return root; } private: TreeNode* root; }; templateTree ::Tree() { root = NULL; } templateTree ::~Tree() { } templatevoid Tree ::CreateTree(TreeNode*& t) { T x; cin >> x; if (x == '#') { t = NULL; return; } t = new TreeNode(x); if (t == NULL) return; CreateTree(t>leftchild); CreateTree(t>rightchild); } templatevoid Tree ::PreTra_inden(TreeNode* t,int n) { if (t != NULL) { n++; for(int i=1;i<=n;i++) cout << ''; cout<< t>data << endl; PreTra_inden(t>leftchild,n); PreTra_inden(t>rightchild,n); } } templatevoid Tree ::deleTree(TreeNode* t) { if (t == NULL) return; deleTree(t>leftchild); deleTree(t>rightchild); delete t; } int main() { Treetemp; TreeNode * head = temp.Get_root(); temp.CreateTree(head); temp.PreTra_inden(head,0); temp.deleTree(head); return 0; }
Problem1630:#includeusing namespace std; template struct TreeNode { T data; TreeNode * leftchild; TreeNode* rightchild; TreeNode() { leftchild = NULL; rightchild = NULL; } TreeNode(T x) { data = x; leftchild = NULL; rightchild = NULL; } }; templateclass Tree { public: Tree(); ~Tree(); void CreateTree(TreeNode *& t); void deleTree(TreeNode* t); void count(TreeNode* t, int& i, int& j, int& k); TreeNode* Get_root() { return root; } private: TreeNode* root; }; templateTree ::Tree() { root = NULL; } templateTree ::~Tree() { } templatevoid Tree ::CreateTree(TreeNode*& t) { T x; cin >> noskipws >> x; if (x == '#'|| x == '\n') { t = NULL; return; } t = new TreeNode(x); if (t == NULL) return; CreateTree(t>leftchild); CreateTree(t>rightchild); } templatevoid Tree ::deleTree(TreeNode* t) { if (t == NULL) return; deleTree(t>leftchild); deleTree(t>rightchild); delete t; } templatevoid Tree ::count(TreeNode* t, int& i, int& j, int& k) { if (t != NULL) { if (t>leftchild == NULL && t>rightchild == NULL) k++; if (t>leftchild == NULL && t>rightchild != NULL || t>leftchild != NULL && t>rightchild == NULL) j++; if (t>leftchild != NULL && t>rightchild != NULL) i++; count(t>leftchild, i, j, k); count(t>rightchild, i, j, k); } } int main() { Treetemp; TreeNode * head = temp.Get_root(); int i = 0, j = 0, k = 0; temp.CreateTree(head); temp.count(head, i, j, k); temp.deleTree(head); cout << k << ' ' << j << ' ' << i <<' '; return 0; }
Problem1630:#includeusing namespace std; template struct TreeNode { T data; TreeNode * leftchild; TreeNode* rightchild; TreeNode() { leftchild = NULL; rightchild = NULL; } TreeNode(T x) { data = x; leftchild = NULL; rightchild = NULL; } }; templateclass Tree { public: Tree(); ~Tree(); void CreateTree(TreeNode *& t); void deleTree(TreeNode* t); void count(TreeNode* t, int& i, int& j, int& k); TreeNode* Get_root() { return root; } private: TreeNode* root; }; templateTree ::Tree() { root = NULL; } templateTree ::~Tree() { } templatevoid Tree ::CreateTree(TreeNode*& t) { T x; cin >> noskipws >> x; if (x == '#') { t = NULL; return; } t = new TreeNode(x); if (t == NULL) return; CreateTree(t>leftchild); CreateTree(t>rightchild); } templatevoid Tree ::deleTree(TreeNode* t) { if (t == NULL) return; deleTree(t>leftchild); deleTree(t>rightchild); delete t; } templatevoid Tree ::count(TreeNode* t, int& i, int& j, int& k) { if (t != NULL) { if (t>leftchild == NULL && t>rightchild == NULL) k++; if (t>leftchild == NULL && t>rightchild != NULL || t>leftchild != NULL && t>rightchild == NULL) j++; if (t>leftchild != NULL && t>rightchild != NULL) i++; count(t>leftchild, i, j, k); count(t>rightchild, i, j, k); } } int main() { Treetemp; TreeNode * head = temp.Get_root(); int i = 0, j = 0, k = 0; temp.CreateTree(head); temp.count(head, i, j, k); temp.deleTree(head); cout << k << ' ' << j << ' ' << i <<' '; return 0; }
Problem1633:#includeusing namespace std; template struct TreeNode { T data; TreeNode * leftchild; TreeNode* rightchild; TreeNode() { leftchild = NULL; rightchild = NULL; } TreeNode(T x) { data = x; leftchild = NULL; rightchild = NULL; } }; templateclass Tree { public: Tree(); ~Tree(); void CreateTree(TreeNode *& t); void deleTree(TreeNode* t); void input(); void search(TreeNode* t, const T& x, int& flag); TreeNode* root; }; templateTree ::Tree() { root = NULL; } templateTree ::~Tree() { } templatevoid Tree ::CreateTree(TreeNode*& t) { T x; cin >> x; if (x == '#') { t = NULL; return; } t = new TreeNode(x); if (t == NULL) return; CreateTree(t>leftchild); CreateTree(t>rightchild); } templatevoid Tree ::deleTree(TreeNode* t) { if (t == NULL) return; deleTree(t>leftchild); deleTree(t>rightchild); delete t; } templatevoid Tree ::input() { T x; int flag = 0; while(cin >> x && x != '#') { flag = 0; search(root, x, flag); if (flag == 0) cout << "failure" << endl; } } templatevoid Tree ::search(TreeNode* t,const T& x,int& flag) { if (t != NULL) { if (x == t>data) { flag = 1; cout << "success" << endl; } search(t>leftchild, x, flag); search(t>rightchild, x, flag); } } int main() { Treetemp; temp.CreateTree(temp.root); temp.input(); temp.deleTree(temp.root); return 0; }
Problem1635:#include using namespace std; template struct TreeNode { T data; TreeNode * leftchild; TreeNode* rightchild; TreeNode() { leftchild = NULL; rightchild = NULL; } TreeNode(T x) { data = x; leftchild = NULL; rightchild = NULL; } }; templateclass Tree { public: Tree(); ~Tree(); void CreateTree(TreeNode *& t); void deleTree(TreeNode* t); void output(TreeNode* t,char s[],int& n); TreeNode* root; }; templateTree ::Tree() { root = NULL; } templateTree ::~Tree() { } templatevoid Tree ::CreateTree(TreeNode*& t) { T x; cin >> x; if (x == '#') { t = NULL; return; } t = new TreeNode(x); if (t == NULL) return; CreateTree(t>leftchild); CreateTree(t>rightchild); } templatevoid Tree ::deleTree(TreeNode* t) { if (t == NULL) return; deleTree(t>leftchild); deleTree(t>rightchild); delete t; } templatevoid Tree ::output(TreeNode* t, char s[],int& n) { if (t != NULL) { output(t>leftchild, s, n); s[n++] = t>data; output(t>rightchild, s, n); } } templatebool judge(Tree & t1, Tree& t2) { T s1[100] = { 0 }, s2[100] = { 0 }; int n1 = 0, n2 = 0; t1.output(t1.root, s1, n1); t2.output(t2.root, s2, n2); if (n1 != n2) return false; else { for (int i = 0; i < n1; i++) { if (s1[i] != s2[i]) return false; } return true; } } int main() { Treet1,t2; t1.CreateTree(t1.root); t2.CreateTree(t2.root); if (judge(t1, t2)) cout << "equal" << endl; else cout << "not equal" << endl; t1.deleTree(t1.root); t2.deleTree(t2.root); return 0; }
Problem1656:#include int main() { int n,sum,i; while(1) { scanf("%d",&n); if(n==0) break; sum=0; for(i=5;i<=n;i*=5) { sum+=n/i; } printf("%d\n",sum); } return 0; }
Problem1692:#include #include #include#include #include using namespace std; int main() { string name[100]; int n; cin >> n; for (int i = 0; i < n; i++) cin >> name[i]; string change; for(int i=0;i name[j + 1]) { change = name[j]; name[j] = name[j + 1]; name[j + 1] = change; } for (int i = 0; i < n1; i++) cout<< name[i]<<','; cout << name[n  1] ; return 0; }
Problem1693:#include"iostream" #include"iomanip" using namespace std; void values_change(double* a, double* b) { double c; if (*a > *b) { c = *b; *b = *a; *a = c; } } int main() { double m, n; cin >> m >> n; values_change(&m, &n); cout << fixed << setprecision(2) << m <<" " << n< int main() { int a,b,*p1,*p2; p1=&a; p2=&b; scanf("%d%d",p1,p2); printf("%d %d",(*p1)/(*p2),*p1%*p2); return 0; } 
Problem1747:#include #include using namespace std; int main() { int f; double sum; cin >> f; sum = static_cast ((f  32)) * 5 / 9.0; cout << fixed << setprecision(2) << sum << endl; return 0; }
Problem1748:#include#include using namespace std; int main() { int f; double sum; cin >> f; sum = static_cast (f) * 9 / 5 + 32; cout << fixed << setprecision(2) << sum << endl; return 0; }
Problem1751:#include#include using namespace std; int main() { int n; cin >> n; double sum=0; for (int i = 2; i <= n; i+=2) { sum += 1 / static_cast (i); } cout << fixed << setprecision(2) << sum << endl; return 0; }
Problem1752:#include#include using namespace std; int main() { int n; cin >> n; double sum=0; for (int i = 1; i <= n; i+=2) { sum += 1 / static_cast (i); } cout << fixed << setprecision(2) << sum << endl; return 0; }
Problem1763:#include#include using namespace std; int main() { int n; cin >> n; double sum = 0; for (int i = 1; i <= n; i++) sum += 1 / static_cast (i); cout << fixed << setprecision(3) << sum << endl; return 0; }
Problem1771:#include#include using namespace std; int main() { int sum = 0; for (int i = 100; i <= 999; i++) { if (i % 3 == 0 && i % 5 == 0) sum += i; } cout << sum << endl; return 0; }
Problem1771:#include #include using namespace std; int main() { cout << 32850 << endl; return 0; }
Problem1787:#include #include #includeusing namespace std; int main() { string s; getline(cin, s); int len = s.length(); for (int i = 0; i < len; i++) { if(islower(s[i])) s[i]=32; if (isdigit(s[i])) { s.erase(i, 1); i; len = s.length(); } } cout << s; return 0; } 
Problem1788:#include #include #include#include #include using namespace std; class triangle { public: triangle(float i=3, float j=4, float k=5):a(i),b(j),c(k) {} void assign(float& i, float& j, float& k) { a = i; b = j; c = k; } float area() { float p; p = (a + b + c) / 2.0; return sqrt(p * (p  a) * (p  b)*(p  c)); } private: float a; float b; float c; }; int main() { triangle t1, t2; cout << fixed << setprecision(2) << t1.area() << endl; float a, b, c; cin >> a >> b >> c; t2.assign(a, b, c); cout << t2.area() << endl; } 
Problem1789:#include #include #include#include #include using namespace std; class weekday { public: weekday() { string b[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; for (int i = 0; i < 7; i++) s[i] = b[i]; } weekday(string a) :date(a) { string b[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; for (int i = 0; i < 7; i++) s[i] = b[i]; } weekday operator +(int n) { int m; for (int i = 0; i < 7; i++) if (date == s[i]) m = i + 1; int all = (m + n) % 7; weekday temp(s[all  1]); return temp; } void display() { cout << date << endl; } private: string date; string s[7]; }; int main() { int n; cin >> n; weekday w1("Mon"); weekday w2 = w1 + n; w2.display(); } 
Problem1794:#include"iostream" #include"iomanip" #include"cmath" using namespace std; bool judge_prinme(int n)//判断质数 { if (n <= 3) { return n > 1;//如果n<3,只可能是1.2.3,2.3为质数,1既不是质数也不是合数. } if (n % 6 != 1 && n % 6 != 5) return false; int t = static_cast (sqrt(n)) + 1; for (int i = 5; i < t; i += 6) { if (n % i == 0) { return false; } } return true; } void decomp_prinme(int& n)//分解整数 { if (n != 1) { for (int i = 2; i <= n; i++) { if (n % i == 0) { n = n / i; cout << i << " "; decomp_prinme(n); } } } else return ; } int main() { int n; cin >> n; if (judge_prinme(n)) cout << n << endl; else decomp_prinme(n); return 0; } 
Problem1795:#include"iostream" #include"iomanip" #include"cmath" using namespace std; class Fraction { public: Fraction():molecular(0),denominator(1) { } void Assiginment(int m, int n) { molecular = m; denominator = n; } ~Fraction() { } int Gcd(int m, int n) { int temp; if (m == 0 || n == 0) return 0; if (m < n) { temp = m; m = n; n = temp; } while (n != 0) { temp = n; n = m % n; m = temp; } return temp; } int Lcm(int m, int n) { int t; int gcd = Gcd(m, n); t = m * n / gcd; return t; } void Simplification() { int gcd = Gcd(denominator, molecular); denominator /= gcd; molecular /= gcd; } void add(Fraction* t,int& i,int n) { if (i < n) { if (t[i].denominator == denominator) { molecular += t[i].molecular; this>Simplification(); } else { int lcm; lcm = Lcm(t[i].denominator, denominator); int m, n; m = lcm / t[i].denominator * t[i].molecular; n = lcm / denominator * molecular; denominator = lcm; molecular = m + n; this>Simplification(); } i++; this>add(t, i, n); } else return; } void display() { if (denominator == 1) { cout << molecular << endl; } else { cout << molecular << "/" << denominator << endl; } } private: int molecular; int denominator; }; int main() { int n; int a, b; char mid; Fraction* fra; cin >> n; fra = new Fraction[n]; for (int i = 0; i < n; i++) { cin >> a >> mid >> b; fra[i].Assiginment(a, b); } Fraction sum; int i = 0; sum.add(fra,i,n); sum.display(); return 0; }
Problem1796:#includeusing namespace std; int main() { int man[1000], woman[1000]; int m, n, k; cin >> m >> n >> k; int count = 1; for (int i = 0; i < m; i++) man[i] = count++; count = 1; for (int i = 0; i < n; i++) woman[i] = count++; count = 0; while (k) { cout << man[count % m] << " " << woman[count % n] << endl; count++; } return 0; }
Problem1797:#include #include"iomanip" using namespace std; int count(int n,int f[]) { if (f[n] !=0) { return f[n]; } else { if (n % 2 == 0) { f[n] = f[n  1] + f[n / 2]; return count(n  1, f) + count(n / 2, f); } else { f[n] = f[n  1]; return count(n  1, f); } } } int main() { int f[1001] = {}; f[1] = 1; int n; cin >> n; cout << count(n,f) << endl; return 0; }
Problem1798:#include using namespace std; void load(int n,int k,int& count) { if ((n  k) % 2 == 0 && n > k) { load((n  k) / 2, k, count); load((n  k) / 2 + k, k, count); } else count++; } int main() { int N, K; cin >> N >> K; int count = 0; load(N, K, count); cout << count << endl; return 0; } 
Problem1804:#include #include #include int main() { int i,k,t,sum,ys; char ls,a[18],b[18],c[11]={'1','0','X','9','8','7','6','5','4','3','2'}; scanf("%d",&t); getchar(); while(t) { k=0; gets(a); for(i=0;i<15;i++) { if(i==6) { b[k++]='1'; b[k++]='9'; b[k++]=a[i]; } else b[k++]=a[i]; } b[k]='\0'; for(i=0;b[i]!=0;i++) b[i]=b[i]48; sum=b[0]*7+b[1]*9+b[2]*10+b[3]*5+b[4]*8+b[5]*4+b[6]*2+b[7]*1+b[8]*6+b[9]*3+b[10]*7+b[11]*9+b[12]*10+b[13]*5+b[14]*8+b[15]*4+b[16]*2; ys=sum%11; ls=c[ys]; for(i=0;i<17;i++) printf("%d",b[i]); printf("%c\n",ls); } return 0; } 
Problem1812:#include int main() { double d; while(scanf("%lf",&d)!=EOF) printf("%lf\n", 4.0/3.0*3.141592653589793*(d/2)*(d/2)*(d/2)) ; return 0; } 
Problem1813:#include int main() { int n,sum,i,m; scanf("%d",&m); while(m) { scanf("%d",&n); if(n==0) break; sum=0; for(i=5;i<=n;i*=5) { sum+=n/i; } printf("%d\n",sum); } return 0; } 
Problem1814:#include int main() { int i,n,a[45]={1,1}; while(scanf("%d",&n)!=EOF) { for(i=2;i int main() { int a[100]={1,1},i,m,sum=0; while(scanf("%d",&m)!=EOF) { sum=0; if(m==1||m==2) sum=1; else { for(i=2;i #include int s(int x,int y); int main() { int n,sum,i,m,gcd,icm; while(scanf("%d%d",&m,&n)!=EOF) { gcd=s(m,n); icm=m*n/gcd; printf("%d %d\n",gcd,icm); } return 0; } int s(int x,int y) { int t,mid; if(x>y){t=x;x=y;y=t;} do{ mid=y%x; y=x; x=mid; }while(x!=0); return y; } 
Problem1827:#include #include int count(int *p,int *q); int main() { int i,n,a[20]; scanf("%d",&n); for(i=0;i =100&&p[i]<=999) cou++; return cou; } 
Problem1834:#include#include #include using namespace std; class student { public: student(); void display(); int get_age() { return age; } private: int age; string name; int number; static int n; }; int student::n = 1; student::student() { cin >> name >> age; number = n++; } void student::display() { cout << number << ' ' << name << ' ' << age << endl; } int main() { student s[5]; float avg = 0.0; for (int i = 0; i < 5; i++) { s[i].display(); } double ave = 0; for (int i = 0; i < 5; i++) ave += s[i].get_age(); cout << fixed << setprecision(2) << ave / 5 << endl; return 0; }
Problem1843:#include #include using namespace std; class student { public: student(); void input(); void sum(); void display(); private: string name; string num; int a, b, c; int t; }; student::student() {} void student::input() { cin >> num >> name >> a >> b >> c; } void student::sum() { t = a + b + c; } void student::display() { cout << name << ' ' << t << endl; } int main() { int n; student* p; cin >> n; p = new student[n]; for (int i = 0; i < n; i++) (p+i)>input(); for (int i = 0; i < n; i++) (p + i)>sum(); for (int i = 0; i < n; i++) (p+i)>display(); return 0; }
Problem1860:#include int main() { int a[10][10],b[10][10],c[10][10],m,n,i,j; scanf("%d%d",&m,&n); for(i=0;i int main() { char a[100],b[100]; int i,m,n,k; k=0; scanf("%d%d\n",&m,&n); gets(a); for(i=m;i<=n;i++) { b[k++]=a[i]; } b[k]='\0'; puts(b); return 0; }
Problem1861:#include int main() { char a[100],b[100]; int i,m,n,k; k=0; scanf("%d%d",&m,&n); getchar(); gets(a); for(i=m;i<=n&&a[i]!='\0';i++) { b[k++]=a[i]; } b[k]='\0'; puts(b); return 0; }
Problem1862:#include #include #include int prime(int x) { int i,k; k=sqrt(x)+1; for(i=2;i<=k;i++) if(0==x%i) return 0; return 1; } int main() { int m,j; scanf("%d",&m); j=prime(m); if(1==j) printf("Yes"); else printf("No"); return 0; }
Problem1863:#include int sum(int x); int main() { int m,s; scanf("%d",&m); s=sum(m); printf("%d",s); return 0; } int sum(int x) { int sum; sum=0; do{ sum=sum+(x%10); x=x/10; }while(x!=0); return sum; } 
Problem1864:#include int s(int x,int y); int main() { int m,n,a,b; scanf("%d%d",&m,&n); a=s(m,n); b=m*n/a; printf("%d %d",a,b); return 0; } int s(int x,int y) { int t,mid; if(x>y){t=x;x=y;y=t;} do{ mid=y%x; y=x; x=mid; }while(x!=0); return y; } 
Problem1864:#include #include int max(int a,int b) { int i,max; for(i=1;i<=a&&i<=b;i++) { if(a%i==0&&b%i==0) { max=i; } } return max; } int min(int a,int b) { int i,gy,max; for(i=1;i<=a&&i<=b;i++) { if(a%i==0&&b%i==0) { max=i; } } gy=a*b/max; return gy; } int main() { int m,n,i,j; scanf("%d %d",&m,&n); i=max(m,n); j=min(m,n); printf("%d %d",i,j); } 
Problem1865:#includeint sum(int x); int main() { int m,n,a,b; scanf("%d",&n); a=sum(n); printf("%d",a); return 0; } int sum(int x) { int a[100]={1,1},i,sum; for(i=2;i char del(char b[],char c[100]); int main() { char a[100],c[100]; gets(a); del(a,c); puts(c); return 0; } char del(char b[],char c[100]) { int i,k; k=0; for(i=0;b[i]!='\0';i++) { if(b[i]=='*') continue; c[k++]=b[i]; } c[k]='\0'; } 
Problem1866:#include void ave(char x[],char y[]); int main() { char a[100],s[100]; gets(a); ave(a,s); puts(s); return 0; } void ave(char x[],char y[]) { int i,k=0; for(i=0;x[i]!='\0';i++) { if(x[i]=='*') continue; y[k++]=x[i]; } y[k]='\0'; }
Problem1867:#include void ave(char x[],char y[],char z[]); int main() { char a[100],b[100],s[200]; gets(a); gets(b); ave(a,b,s); puts(s); return 0; } void ave(char x[],char y[],char z[]) { int i,k=0; for(i=0;x[i]!='\0';i++) { z[k++]=x[i]; } for(i=0;y[i]!='\0';i++) { z[k++]=y[i]; } z[k]='\0'; }
Problem1868:#include double ave(); int main() { double stu_num,grade; scanf("%lf",&stu_num); grade=ave(); printf("%.0lf %.3lf",stu_num,grade); return 0; } double ave() { double a[8],sum,ave; int i; for(i=0;i<8;i++) scanf("%lf",&a[i]); for(i=0;i<8;i++) sum=sum+a[i]; ave=sum/i; return ave; } 
Problem1868:#include double ave(double x[]); int main() { double a,b,s[8]; int i; scanf("%lf",&a); for(i=0;i<8;i++) scanf("%lf",&s[i]); b=ave(s); printf("%.0lf %.3lf",a,b); return 0; } double ave(double x[]) { double ave,sum; int i; sum=0; for(i=0;i<8;i++) { sum=sum+x[i]; } ave=sum/8; return ave; }
Problem1869:#include void turn(char x[]); int main() { char a[100]; gets(a); turn(a); puts(a); return 0; } void turn(char x[]) { int i; for(i=0;x[i]!='\0';i++) { if(x[i]>='0'&&x[i]<='9') { x[i]='0'+'9'x[i]; } } } 
Problem1870:#include char del(char b[],char d[]); int main() { char a[100],c[100]; gets(a); del(a,c); puts(c); return 0; } char del(char b[],char d[]) { int i,k; k=0; for(i=0;b[i]!='\0';i++) { if(0==i%3&&i!=0) d[k++]=' '; d[k++]=b[i]; } d[k]='\0'; } 
Problem1870:#include void s(char a[],char b[]); int main() { char a[100],b[100]; gets(a); s(a,b); puts(b); return 0; } void s(char a[],char b[]) { int i,k=0; for(i=0;a[i]!='\0';i++) { if(i%3==0&&i!=0) b[k++]=' '; b[k++]=a[i]; } b[k]='\0'; }
Problem1871:#include #include #include int main() { int m,n,i,k,j; char a[100],b[100]; scanf("%d%d",&m,&n); k=0; getchar(); gets(a); for(i=0;a[i]!='\0';i++) { if(i>=m&&i<=m+n1) continue; else { b[k++]=a[i]; b[k]='\0'; } } puts(b); return 0; }
Problem1872:#include int main() { char a[100],b[100]; int i,k; gets(a); k=0; for(i=0;a[i]!='\0';i++) { if(a[i]>='0'&&a[i]<='9') b[k++]=a[i]; } b[k]='\0'; for(i=0;b[i]!='\0';i++) { printf("%c",b[i]); } return 0; }
Problem1873:#include int turn(int x); int main() { int n,m; scanf("%d",&n); m=turn(n); printf("%d",m); return 0; } int turn(int x) { int sum=0,i; do{ i=x%10; if(0==i%2) { sum=sum*10+i; } x=x/10; }while(x!=0); return sum; } 
Problem1874:#include int main() { char a[100],b[100],x; int i,k; gets(a); k=0; scanf("%c",&x); for(i=0;a[i]!='\0';i++) { if(a[i]==x) { continue; } else b[k++]=a[i]; } for(i=0;b[i]!='\0';i++) a[i]=b[i]; a[i]='\0'; puts(a); return 0; } 
Problem1875:#include int main() { char a[100],b[100]; int i,k; gets(a); k=0; for(i=0;a[i]!='\0';i++) { b[k++]=a[i]; } k=i; for(i=0;a[i]!='\0';i++) { if(a[i]!=b[k1i]&&a[i]!=b[k1i]+32&&a[i]+32!=b[k1i]) break; } if(k==i) printf("Yes"); else printf("No"); return 0; } 
Problem1876:#include int main() { int i,j; char s[200]; gets(s); j=0; for(i=0;s[i]!='\0';i++) if(s[i]!=' '&&(s[i+1]==' '||s[i+1]=='\0')) j++; printf("%d",j); return 0; } 
Problem1877:#include void sort(int b[]); int main() { int a[10],i; while(scanf("%d",&a[0])!=EOF) { for(i=1;i<10;i++) scanf("%d",&a[i]); sort(a); } return 0; } void sort(int b[]) { int i,j,t; for(i=0;i<9;i++) for(j=0;j<9;j++) { if(b[j]>b[j+1]) { t=b[j]; b[j]=b[j+1]; b[j+1]=t; } } for(i=0;i<10;i++) { if(i==9) printf("%d\n",b[i]); else printf("%d ",b[i]); } } 
Problem1877:#include void sort(int a[]); int main() { int a[10],i; while(scanf("%d",&a[0])!=EOF) { for(i=1;i<10;i++) scanf("%d",&a[i]); sort(a); for(i=0;i<10;i++) { if(9==i) printf("%d\n",a[i]); else printf("%d ",a[i]); } } return 0; } void sort(int a[]) { int i,j,t; for(i=0;i<9;i++) for(j=i+1;j<10;j++) { if(a[i]>a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } }
Problem1878:#include double ave(double x,double y); int main() { double a,b,s; scanf("%lf%lf",&a,&b); s=ave(a,b); printf("%.1lf",s); return 0; } double ave(double x,double y) { double ave; ave=(x+y)/2; return ave; }
Problem1879:#include #include #include int sum(int n); int main() { int n,y; scanf("%d",&n); y=sum(n); printf("%d",y); return 0; } int sum(int n) { if(n/10==0) return n; else return(sum(n/10)+n%10); }
Problem1880:#include #include using namespace std; double fun(double x, int n) { if (n == 0) return 1; else { if (n == 1) return x; else if (n >= 2) return (static_cast ((2 * n  1)) * x * fun(x, n  1)  static_cast((n  1)) * fun(x, n  2)) / static_cast(n); } } int main() { int n; double result, x; cin >> n >> x; result = fun(x, n); cout << fixed << setprecision(2) << result << endl; return 0; } 
Problem1881:#includedouble ave(double a[],double *p1,double *p2); int main() { int i; double a[100],aver,n; scanf("%lf",&n); for(i=0;i void ave(double *p,double *p1,double *p2); int main() { double a[100],aver,n; int i; scanf("%lf",&n); for(i=0;i #include int max(int *p1,int *p2,int *p3); int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); printf("%d",max(&a,&b,&c)); return 0; } int max(int *p1,int *p2,int *p3) { int max; max=*p1; if(*p2>max)max=*p2; if(*p3>max)max=*p3; return max; } 
Problem1883:#include int f(int a[],int *p1,int *p2); int main() { int a[10],i,x,n; scanf("%d",&n); for(i=0;i int s(int *p,int *p1,int *p2); int main() { int a[10],i,n,t; scanf("%d",&n); for(i=0;i void change(char *p); int main() { char a[100]; gets(a); change(a); puts(a); return 0; } void change(char *p) { while(*p) { if(*p>='a'&&*p<='z') *p=*p32; p++; } } 
Problem1885:#include #include double sn(double x); int main() { int n; scanf("%d",&n); printf("%lf",sn(n)); return 0; } double sn(double x) { double i,sn; sn=0; for(i=1;i<=x;i++) sn=sn+1/((i+1)*i); return sn; } 
Problem1886:#include int max(int a[][10],int m); int main() { int a[2][10],m,i,j,n; scanf("%d",&m); for(i=0;i<2;i++) for(j=0;j n) n=a[i][j]; return n; }
Problem1887:#includevoid s(char *p); int main() { char a[100]; gets(a); s(a); puts(a); return 0; } void s(char *p) { int i,j,t; for(i=0;*(p+i);i++) for(j=i+1;*(p+j);j++) if(*(p+i)>*(p+j)) { t=*(p+i); *(p+i)=*(p+j); *(p+j)=t; } } 
Problem1888:#include #include int str(char *p); int main() { int n,i; char max[100],mid[100]; scanf("%d",&n); getchar(); gets(max); for(i=0;i str(max)) strcpy(max,mid); } puts(max); return 0; } int str(char *p) { int i,j=0; for(i=0;*(p+i);i++) j++; return j; } 
Problem1888:#include#include int main() { char *p1,*p2,a[100],b[100]; int i,n; scanf("%d",&n); getchar(); gets(b); p1=a;p2=b; for(i=0;i strlen(p2)) strcpy(p2,p1); } puts(p2); return 0; } 
Problem1889:#include#include void change(char *p); int main() { char a[100]; gets(a); change(a); puts(a); return 0; } void change(char *p) { int i; for(i=0;p[i];i++) if(p[i]>='a'&&p[i]<='z') p[i]=p[i]32; } 
Problem1890:#include #include void s(char *p1,char *p2); int main() { char a[100],b[100]; gets(a); gets(b); s(a,b); puts(a); return 0; } void s(char *p1,char *p2) { strcat(p1,p2); }
Problem1891:#include #include int s(int *p,int *q); int main() { int i,n,a[100]; scanf("%d",&n); for(i=0;i #include #include struct stu* creat(); void list(struct stu *head); typedef struct stu { double num; char name[50]; int score; struct stu *next; }ST; int main() { ST *h=NULL; h=creat(); list(h); return 0; } ST* creat() { ST *p,*q,*head; p=(ST*)malloc(sizeof(ST)); scanf("%lf %s %d",&p>num,p>name,&p>score); head=p; while(p>num!=0) { q=p; p=(ST*)malloc(sizeof(ST)); scanf("%lf %s %d",&p>num,p>name,&p>score); q>next=p; } q>next=NULL; free(p); return(head); } void list(ST *head) { ST *p; double sum=0,n=0; p=head; while(p!=NULL) { printf("%.0lf %s %d\n",p>num,p>name,p>score); sum=sum+p>score; n++; p=p>next; } printf("%.2lf",sum/n); }
Problem1893:#include #include #include struct score* creat(); void list(struct score *head); typedef struct score { int fs; struct score *next; }CJ; int main() { CJ *h=NULL; h=creat(); list(h); return 0; } CJ* creat() { CJ *p,*q,*head; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); head=p; while(p>fs!=0) { q=p; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); q>next=p; } q>next=NULL; free(p); return(head); } void list(CJ *head) { CJ *p; p=head; while(p!=NULL) { if(p>next==NULL) printf("%d",p>fs); else printf("%d ",p>fs); p=p>next; } }
Problem1898:#include #include #include struct score* creat(); void list(struct score *head); struct score* del(struct score *head); typedef struct score { int fs; struct score *next; }CJ; int main() { CJ *h=NULL; h=creat(); h=del(h); list(h); return 0; } CJ* creat() { CJ *p,*q,*head; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); head=p; while(p>fs!=0) { q=p; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); q>next=p; } q>next=NULL; free(p); return(head); } void list(CJ *head) { CJ *p; p=head; while(p!=NULL) { if(p>next==NULL) printf("%d",p>fs); else printf("%d ",p>fs); p=p>next; } } CJ* del(CJ *head) { CJ *p,*q=NULL; int num; scanf("%d",&num); p=head; while(p>fs!=num&&p>next!=NULL) {q=p;p=p>next;} if(p==head) head=p>next; else q>next=p>next; free(p); return(head); }
Problem1899:#include #include #include struct score* creat(); void list(struct score *head); struct score* del(struct score *head); struct score* add(struct score *head); typedef struct score { int fs; struct score *next; }CJ; int main() { CJ *h=NULL; h=creat(); h=add(h); list(h); return 0; } CJ* creat() { CJ *p,*q,*head; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); head=p; while(p>fs!=0) { q=p; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); q>next=p; } q>next=NULL; free(p); return(head); } void list(CJ *head) { CJ *p; p=head; while(p!=NULL) { if(p>next==NULL) printf("%d",p>fs); else printf("%d ",p>fs); p=p>next; } } CJ* del(CJ *head) { CJ *p,*q=NULL; int num; scanf("%d",&num); p=head; while(p>fs!=num&&p>next!=NULL) {q=p;p=p>next;} if(p==head) head=p>next; else q>next=p>next; free(p); return(head); } CJ* add(CJ *head) { CJ *p,*q1,*q2; p=(CJ*)malloc(sizeof(CJ)); scanf("%d",&p>fs); q1=head; while(p>fs>q1>fs&&q1>next!=NULL) {q2=q1;q1=q1>next;} if(p>fs<=head>fs) { p>next=head; head=p; } else if(q1>next==NULL) { q1>next=p; p>next=NULL; } else { q2>next=p; p>next=q1; } return head; }
Problem1900:#include int main() { char c; c=getchar(); if (c >= 65 && c <= 90) printf("upper"); else if (c >= 97 && c <= 122) printf("lower"); else if (c >= 48 && c <= 57) printf("digit"); else printf("other"); return 0; }
Problem1909:#include int main() { int mid1,mid2,n,m,i,k; while(scanf("%d",&n)!=EOF) { i=k=n; while(1) { for(m=1;(m*m)<=i;m++) if((m*m)==i) { mid1=i; break; } if(m*m==i) break; i++; } while(1) { for(m=1;(m*m)<=k;m++) if((m*m)==k) { mid2=k; break; } if(m*m==k) break; k; } if((mid1n)<(nmid2)) printf("%d\n",mid1); else printf("%d\n",mid2); } return 0; }
Problem1913:#include int main() { int n,x,y,i,sum1,sum2; while(scanf("%d",&n)!=EOF) { sum1=0; sum2=0; if(n%2==0||n==0) { scanf("%d%d",&x,&y); for(i=x;i<=y;i++) if(i%2==0||i==0) sum1++; printf("%d\n",sum1); } else { scanf("%d%d",&x,&y); for(i=x;i<=y;i++) sum2=sum2+i; printf("%d\n",sum2); } } return 0; }
Problem1914:#include #include int prime(int x); int main() { int i,r,m,n,sum; while(scanf("%d%d",&m,&n)!=EOF) { while(n) { sum=0; scanf("%d%d",&i,&r); if(r #include #include using namespace std; class Date { public: Date(int y = 2008, int m = 1, int d = 1); void assign(int y, int m, int d); void display(); bool leap_year(); int get_month_days(int m); void increment(int n); void decrement(int n); private: int year; int month; int day; }; Date::Date(int y, int m, int d) :year(y), month(m), day(d) { } void Date::assign(int y, int m, int d) { year = y; month = m; day = d; } void Date::display() { cout << year << '' << month << '' << day << endl; } bool Date::leap_year() { if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return(true); else return (false); } int Date::get_month_days(int m) { int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; if (leap_year()) month[1] = 29; return month[m  1]; } void Date::increment(int n) { while(n) { day++; int mon_days = get_month_days(month); if (day > mon_days) day = 1, month++; if (month > 12) month = 1, year++; } } void Date::decrement(int n) { while (n) { day; if (day < 1) { month; if (month < 1) month = 12, year; day = get_month_days(month); } } } int main() { Date date1, date2(2016, 5, 1), date3, date4; int n, day, month, year; date1.display(); date2.display(); cin >> year >> month >> day; date3.assign(year, month, day); date3.display(); cin >> n; date3.increment(n); date3.display(); date3.assign(year, month, day); date3.decrement(n); date3.display(); return 0; }
Problem1931:#include using namespace std; class matrix { public: matrix(int m,int n); int at(int n); int at(int i,int j); void display(); int get_rows() { return i; } int get_cols() { return j; } int sum(); void transpose(); void reverse_row(); void reverse_col(); private: int i, j; int s[10][10]; }; matrix::matrix(int m, int n) :i(m), j(n) { int flag=1; int a, b; for (a = 0; a < i; a++) for (b = 0; b < j; b++) s[a][b]=flag++; } int matrix::at(int n) { int a, b; for(a=0;a > rows >> cols; matrix mat(rows, cols); mat.display(); cout << endl; cout << mat.at(rows * cols  2) << endl; cout << mat.at(rows  1, cols  1) << endl; cout << mat.sum() << endl; cout << endl; mat.transpose(); mat.display(); cout << endl; mat.reverse_row(); mat.display(); cout << endl; mat.reverse_col(); mat.display(); cout << endl; cout << mat.get_rows() << endl; cout << mat.get_cols() << endl; return 0; }
Problem1932:#includeusing namespace std; class fraction { public: fraction(); fraction(int x, int y); void display(); void reduction(); void assign(int x, int y); int get_num(); private: int a; int b; }; fraction::fraction():a(0), b(1) {} fraction::fraction(int x, int y):a(x),b(y) {} void fraction::display() { if (b == 1) cout << a << endl; else { reduction(); if (b == 1) cout << a << endl; else cout << a << "/" << b << endl; } } void fraction::reduction() { int mid; mid = get_num(); a = a / mid; b = b / mid; } void fraction::assign(int x, int y) { a = x; b = y; } int fraction::get_num() { int i; for (i = a; i >=2; i) if (a % i == 0 && b % i == 0) return i; return 1; } int main() { int x, y; fraction f1(3, 8), f2(8, 4), f3; f1.display(); f2.display(); f3.display(); cin >> x >> y; f3.assign(x, y); f3.display(); return 0; }
Problem1933:#include using namespace std; class time24 { public: time24(int h = 0, int m = 0, int s = 0); void set_time(int h, int m, int s); void get_time(int& h, int& m, int& s); time24 operator+(int s); time24 operator+(time24 t); time24 operator(int s); time24 operator(time24 t); private: int hours; int minutes; int seconds; }; time24::time24(int h, int m, int s) :hours(h), minutes(m), seconds(s) {} void time24::set_time(int h, int m, int s) { hours = h; minutes = m; seconds = s; } void time24::get_time(int& h, int& m, int& s) { h = hours; m = minutes; s = seconds; } time24 time24::operator+(int s) { time24 temp; temp.seconds=seconds + s; temp.minutes=minutes + temp.seconds / 60; temp.seconds %= 60; temp.hours =hours+ temp.minutes / 60; temp.minutes %= 60; temp.hours %= 24; return temp; } time24 time24::operator+(time24 t) { time24 temp; int time; time = t.hours * 3600 + t.minutes * 60 + t.seconds; temp= *this + time; return temp; } time24 time24::operator(int s) { time24 temp; s = s % 86400; temp = *this +(86400 s); return temp; } time24 time24::operator(time24 t) { time24 temp; int time; time = t.hours * 3600 + t.minutes * 60 + t.seconds; temp= *this  time; return temp; } int main() { int h, m, s, secs; time24 t1(0, 59, 57); time24 t2, t3; cin >> secs; t2 = t1 + secs; t2.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; t2 = t2  secs; t2.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; cin >> h >> m >> s; t2.set_time(h, m, s); t3 = t1 + t2; t3.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; t1 = t3  t2; t1.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; } 
Problem1933:#include using namespace std; class time24 { public: time24(int h = 0, int m = 0, int s = 0); void set_time(int h, int m, int s); void get_time(int& h, int& m, int& s); time24 operator+(int s); time24 operator+(time24 t); time24 operator(int s); time24 operator(time24 t); private: int hours; int minutes; int seconds; }; time24::time24(int h, int m, int s) :hours(h), minutes(m), seconds(s) {} void time24::set_time(int h, int m, int s) { hours = h; minutes = m; seconds = s; } void time24::get_time(int& h, int& m, int& s) { h = hours; m = minutes; s = seconds; } time24 time24::operator+(int s) { time24 temp; temp.seconds = seconds + s; temp.minutes = minutes + temp.seconds / 60; temp.seconds %= 60; temp.hours = hours + temp.minutes / 60; temp.minutes %= 60; temp.hours %= 24; return temp; } time24 time24::operator+(time24 t) { time24 temp; int time; time = t.hours * 3600 + t.minutes * 60 + t.seconds; temp = *this + time; return temp; } time24 time24::operator(int s) { time24 temp; int time; time = hours * 3600 + minutes * 60 + seconds; time = time  s % 86400; if (time < 0) time = time + 86400; temp.hours = (time / 3600)%24; temp.minutes = (time % 3600) / 60; temp.seconds = time % 60; return temp; } time24 time24::operator(time24 t) { time24 temp; int time; time = t.hours * 3600 + t.minutes * 60 + t.seconds; temp = *this  time; return temp; } int main() { int h, m, s, secs; time24 t1(0, 59, 57); time24 t2, t3; cin >> secs; t2 = t1 + secs; t2.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; t2 = t2  secs; t2.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; cin >> h >> m >> s; t2.set_time(h, m, s); t3 = t1 + t2; t3.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; t1 = t3  t2; t1.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; }
Problem1934:#include using namespace std; class time24 { public: time24(int h = 0, int m = 0, int s = 0); void set_time(int h, int m, int s); void get_time(int& h, int& m, int& s); time24 operator(); time24 operator(int); bool operator==(time24 t); time24 operator+(int s); private: int hours; int minutes; int seconds; }; time24::time24(int h, int m, int s) :hours(h), minutes(m), seconds(s) {} void time24::set_time(int h, int m, int s) { hours = h; minutes = m; seconds = s; } void time24::get_time(int& h, int& m, int& s) { h = hours; m = minutes; s = seconds; } time24 time24::operator+(int s) { time24 temp; temp.seconds = seconds + s; temp.minutes = minutes + temp.seconds / 60; temp.seconds %= 60; temp.hours = hours + temp.minutes / 60; temp.minutes %= 60; temp.hours %= 24; return temp; } time24 time24::operator() { time24 temp; *this = *this + 86399; temp = *this ; return temp; } time24 time24::operator(int) { time24 temp; temp = *this; *this = *this + 86399; return temp; } bool time24::operator==(time24 t) { if (hours == t.hours && minutes == t.minutes && seconds == t.seconds) return true; else return false; } int main() { int h, m, s; time24 t1; cin >> h >> m >> s; t1.set_time(h, m, s); time24 t2; t2 = t1; if (t1 == t2) cout << "t1==t2" << endl; else cout << "t1!=t2" << endl; t2.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; t2 = t1; if (t1 == t2) cout << "t1==t2" << endl; else cout << "t1!=t2" << endl; t2.get_time(h, m, s); cout << h << ':' << m << ':' << s << endl; } 
Problem1935:#include #include using namespace std; class student { public: student() { } void set(string a,int m,int n) { name = a; age = m; score = n; } void get(string& a, int& m, int& n) { a = name; m = age; n = score; } int get_score() { return score; } private: string name; int age; int score; }; class grade { public: grade(); ~grade(); void display(); void sort(); private: student *p; int num; }; grade::grade() { cin >> num; string a; int m, n; p = new student[num]; for (int i = 0; i < num; i++) { cin >> a >> m >> n; p[i].set(a, m, n); } } void grade::display() { int m, n; string a; for (int i = 0; i < num; i++) { p[i].get(a, m, n); cout << a << ' ' << m << ' ' << n << endl; } } void grade::sort() { student t; for(int i=0;i p[j].get_score()) { t = p[i]; p[i] = p[j]; p[j] = t; } } grade::~grade() { delete[] p; } int main() { grade g; g.display(); g.sort(); g.display(); return 0; }
Problem1936:#include #include #include using namespace std; class Worker { public: virtual void dispaly()=0; virtual int get_money() = 0; }; class AWorker:public Worker { public: AWorker(string a,int t):name(a),money(t) {} void dispaly() { cout << name << ' ' << money << endl; } int get_money() { return money; } private: string name; int money; }; class BWorker :public Worker { public: BWorker(string a, int m,int n) :name(a), hm(m),num(n) {} void dispaly() { cout << name << ' ' << hm*num<< endl; } int get_money() { return hm*num; } private: string name; int hm; int num; }; class CWorker :public Worker { public: CWorker(string a, int m,int n) :name(a), a(m),b(n) {} void dispaly() { cout << name << ' ' << a+b << endl; } int get_money() { return a+b; } private: string name; int a; int b; }; int main() { int num; cin >> num; Worker* p[10]; for (int i = 0; i < num; i++) { cin.ignore(1); char ch; cin.get(ch); cin.ignore(1,' '); if (ch== 'A') { string a; int m; getline(cin, a, ' '); cin >> m; p[i] = new AWorker(a,m); } else if (ch== 'B') { string a; int m,n; getline(cin, a, ' '); cin >> m >> n; p[i] = new BWorker(a, m,n); } else if (ch == 'C') { string a; int m,n; getline(cin, a, ' '); cin >> m >> n; p[i] = new CWorker(a, m, n); } p[i]>dispaly(); } double all=0; for (int i = 0; i < num; i++) all = all + p[i]>get_money(); cout << fixed << setprecision(2) << all / num << endl; return 0; }
Problem1937:#include int main() { char a[]="H e l l o , W o r l d !"; printf("%s", a); return 0; }
Problem1938:#include int main() { char a[]="Hello,World!"; printf("%s", a); return 0; }
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值