典型大数加法题
#include <stdio.h>
#include <string>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string num;
while (cin >> num, num[0] != '0')
{
while (num.length() > 1)
{
string sum = "0";
for (int i = 0; i < num.length(); i++)
{
int temp = num[i] - '0';
int index = 0;
while (temp > 0)
{
if (index == sum.length())
{
sum += "0";
}
int s = (sum[index] - '0') + temp;
sum[index++] = '0' + s % 10;
temp = s / 10;
}
}
num = sum;
}
printf("%s\n", num.c_str());
}
return 0;
}