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!!,看了帖子,那些数据都过了,又哪错了,0开头的也过了,我是无奈了!#include<stdio.h> #include<string.h> #define size 105 char s[size]; int sum[size]; int main() { int i,j,k=0; memset(sum,0,sizeof(sum)); while(gets(s),strcmp(s,"0")) { for(i=(j=strlen(s))-1;i>=0;i--) sum[j-1-i]+=(s[i]-'0');//输入时反转字符串 if(j>k)//记录最大串长度 k=j; for(i=0;i<=k+1;i++) { sum[i+1]+=sum[i]/10; sum[i]=sum[i]%10; } } j=100; while(!sum[j])//滤掉打头的0 j--; if(j<0)//特殊情况,貌似不加也可以 printf("0"); for(i=j;i>=0;i--) printf("%d",sum[i]); printf("\n"); return 0; } 为什么就哇!!!呢,帖子上那些特殊数据都过了,大哥们帮帮忙吧!谢谢了 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator