#include<bits/stdc++.h>
using namespace std;
#include<string.h>
int main()
{
string ar;
long long l,carry=0,c,mx,i,br[200];
memset(br,0,sizeof(br));
while(1)
{
cin>>ar;
//add(ar);
if(ar=="0")
break;
c=0;
carry=0;
mx=-1;
l=ar.length();
for(i=l-1; i>=0; i--)
{
br[c]= ar[i]-'0'+carry+br[c];
carry=br[c]/10;
br[c]=br[c]%10;
c++;
if(mx<c)
mx=c;
}
if(carry>0)
{
while(carry)
{
br[c++]+=carry%10;
carry/=10;
if(mx<c)
mx=c;
}
}
}
for(int i=mx-1; i>=0; i--)
cout<<br[i];
cout<<endl;
return 0;
}
using namespace std;
#include<string.h>
int main()
{
string ar;
long long l,carry=0,c,mx,i,br[200];
memset(br,0,sizeof(br));
while(1)
{
cin>>ar;
//add(ar);
if(ar=="0")
break;
c=0;
carry=0;
mx=-1;
l=ar.length();
for(i=l-1; i>=0; i--)
{
br[c]= ar[i]-'0'+carry+br[c];
carry=br[c]/10;
br[c]=br[c]%10;
c++;
if(mx<c)
mx=c;
}
if(carry>0)
{
while(carry)
{
br[c++]+=carry%10;
carry/=10;
if(mx<c)
mx=c;
}
}
}
for(int i=mx-1; i>=0; i--)
cout<<br[i];
cout<<endl;
return 0;
}
oh !!! Wonderful !!!
ReplyDelete