Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位高手帮我看看为何WA?#include <stdio.h> #include <string.h> #include <stdlib.h> #define MAX 100 char c[MAX+20][MAX+20]; int a[MAX+20][MAX+20]; int d[300]; int main() { int n,i,max,j,k,m; i=0; memset(a,0,sizeof(a)); memset(d,0,sizeof(d)); while(scanf("%s",c[i])!=EOF&&strcmp(c[i],"0")!=0) i++; n=i;max=strlen(c[0]); for(i=0;i<n;i++) {k=strlen(c[i]); if(max<k) max=k; m=0; for(j=k-1;j>=0;j--) a[i][m++]=c[i][j]-'0';} /*for(i=0;i<n;i++) for(j=0;j<max;j++) printf("%d ",a[i][j]); printf("\n");*/ for(j=0;j<max;j++) {for(i=0;i<n;i++) d[j]=d[j]+a[i][j] ;} for(i=0;i<200;i++) if(d[i]>9) { d[i+1]=d[i+1]+d[i]/10; d[i]=d[i]%10; } i=300; while(d[i]==0&&i>0) i--; for(j=i;j>=0;j--) printf("%d",d[j]); printf("\n"); return 0; //system("pause"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator