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(void) { int ans[120]; for(int i=0;i<120;i++) { ans[i]=0; } int flag=0; while(1) { char str[105]; scanf("%s",&str); int len=strlen(str); if(!strcmp(str,"0")) break; flag++; i=119; for(int j=len-1;j>=0;j--,i--) { ans[i]+=(str[j]-'0'); if(ans[i]>9) { ans[i]-=10; ans[i-1]++; } } } while(ans[i]>9&&flag!=0) { ans[i]-=10; ans[i-1]++; i--; } for(i=0;ans[i]==0;i++) ; while(i<120) { printf("%d",ans[i]); i++; } if(flag!=0) { 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