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 |
daima#include<stdio.h> #include<string.h> int main() { char c[1000]={0}; int b[1000]={0}; int i,j,flag,n; while(scanf("%s",c)!=EOF) { n=strlen(c); if(n==1&&c[0]=='0')break; for(i=n-1,j=0;i>=0;i--) { b[j]+=c[i]-'0'; //printf("%d: %d\n",j,b[j]); j++; } } for(i=0;i<1000;i++) if(b[i]>9) { b[i+1]+=b[i]/10; b[i]=b[i]%10; } // printf("**************\n"); flag=0; for(i=999;i>=0;i--) { if(flag||b[i]!=0) { printf("%d",b[i]); flag=1; } if(!flag&&i==0) printf("0"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator