郁闷了就相同的代码在HDUOJ上提交就是AC在NYOJ上提交就是WA字符串处理
#include<stdio.h> #include<string.h> #define N 1000 char x[N],y[N]; int a[N+1]; int main() { int g,h=0; scanf("%d",&g); while(g--) { int k1,k2,t=0,m,n,k,i,j,l; scanf("%s %s",x,y); k1=strlen(x); k2=strlen(y); for(i=k1-1,j=k2-1,l=0;i>=0&&j>=0;i--,j--,l++) { m=x[i]-48; n=y[j]-48; k=(m+n+t)%10; a[l]=k; t=(m+n+t)/10; } while(i>=0) { a[l++]=x[i--]-48+t; t=0; } while(j>=0) { a[l++]=y[j--]-48+t; t=0; } printf("Case %d: ",++h); printf("%s + %s = ",x,y); for(i=l-1;i>=0;i--) printf("%d",a[i]); printf(" "); if(g) printf(" "); } return 0; }