| ||||||||||
| 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 | |||||||||
1Y 附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator