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 |
Re:Why is wrong answer?In Reply To:Why is wrong answer? Posted by:chj8081 at 2008-02-02 17:41:54 > #include <iostream> > #include <string> > //#include <FSTREAM> > using namespace std; > > string rever(string a){ > int l,i; > string s; > l=a.length(); > for(i=l-1;i>=0;i--){ > s+=a[i]; > } > return s; > > } > void main() > { > string ad,re_ad; > int sum[20000]={0},i,tmp,j,adl; > // ifstream in("input.txt"); > while(1){ > cin>>ad; > if(ad[0]=='0') > break; > re_ad=rever(ad); > adl=ad.length(); > > for(i=0;i<adl;i++){ > tmp=sum[i]+re_ad[i]-'0'; > sum[i]=tmp%10; > sum[i+1]+=tmp/10; > } > > } > > for(i=19999;i>=0;i--){ > if(sum[i]!=0){ > for(j=i;j>=0;j--) > cout<<sum[j]; > break; > } > } > > cout<<endl; > > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator