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 |
why wrong?#include<iostream> using namespace std; int main() { int b[200]={0},c[200]={0},l=0; int i,ka,kb,k,o=0; char a1[240],b1[240]; gets(a1);ka=strlen(a1); k=ka; for(i=0;i<ka;i++)c[i]=a1[ka-i-1]-'0'; while(1) { l++; gets(b1); if(strcmp(b1,"0")==0)break; if(b1[0]=='0')for(int w=1;w<strlen(b1);w++){if(b1[w-1]=='0'&&b1[w]=='0')o++;} kb=strlen(b1); if(ka>=kb) k=ka; else k=kb; for(i=0;i<kb-o;i++) b[i]=b1[kb-i-1]-'0'; for(i=0;i<k;i++) { c[i]=b[i]+c[i]; c[i+1]=c[i+1]+c[i]/10; c[i]=c[i]%10; } if(c[k]!=0) k++; } for(i=k-1;i>=0;i--)cout<<c[i];cout<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator