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 |
哪儿错了啊??????????实在不知道少考虑什么了 哪位帮忙看看 #include<stdio.h> #include<string.h> int main() {char num[110]; int mid[110]={0},sum[110]={0}; int i,length,n=0; while(scanf("%s",num),strcmp(num,"0")) {length=strlen(num); for(i=0;i<length;i++) mid[i]=num[length-1-i]-'0'; for(i=0;i<110;i++) {sum[i]+=mid[i]+n; if(sum[i]>9) {sum[i]-=10; n=1; } else n=0; } for(i=0;i<length;i++) {num[i]=' '; mid[i]=0; } } for(i=110;;i--) if(sum[i]!=0) {length=i+1; break; } for(i=0;i<length;i++) printf("%d",sum[length-1-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