HDU oj A + B Problem II

来源:互联网 发布:族脉家谱软件 编辑:程序博客网 时间:2024/05/20 09:43

郁闷了就同样的代码在HDUOJ上提交就是AC在NYOJ上提交就是WA字符串处理

#include<stdio.h>#include<string.h>#define N 1000char 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:\n",++h);  printf("%s + %s = ",x,y);  for(i=l-1;i>=0;i--)   printf("%d",a[i]);  printf("\n");  if(g) printf("\n"); }  return 0;}


1 0