Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

1Y 附代码

Posted by 15038029147 at 2010-08-06 15:26:44
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
    string str;
    int ret[102],L=0;
    memset(ret,0,sizeof(ret));
    while(cin>>str&&str!="0")
    {
         int l=str.length();
         if(L<l)
            L=l;
         for(int i=0;i<l;i++)
            ret[i]+=str[l-1-i]-'0';
    }
    int i;
    for( i=0;i<L;i++)
    {
         ret[i+1]+=ret[i]/10;
         ret[i]%=10;   
    }
    while(!ret[i])i--;
    for(;i>=0;i--)
      cout<<ret[i];
    cout<<endl;
    //system("pause");
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator