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 <iostream> using namespace std; int main() { char a[10][10]; int b[10][10]; int i=0,j; int m=0,w=5; while(gets(a[m])) { w++; m++; } for(i=0;i<w;i++) for(j=0;j<10;j++) b[i][j]=0; for(int k=0;k<w;k++) for(i=strlen(a[k])-1,j=0;i>=0;i--,j++) b[k][j]=a[k][i]-'0'; int len=strlen(a[0]); for(i=1;i<w;i++) if(strlen(a[i])>len) len=strlen(a[i]); int r[10]; for(i=0;i<10;i++) r[i]=0; for(i=0;i<w;i++) for(j=0;j<len;j++) r[j]+=b[i][j]; for(i=0;i<len;i++) if(r[i]>=10) { r[1+i]+=r[i]/10; r[i]%=10; } int flag=0; for(int k=9;k>=0;k--) if(flag) cout<<r[k]; else if(r[k]) { cout<<r[k]; flag=1; } if(!flag) cout<<"0"; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator