#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
while (cin >> s&&s != "0")
{
int n=0;
for (auto a : s)
n += a - '0';
int sum = 0;
while (sum >= 10 || sum == 0)
{
sum = 0;
while (n > 0)
{
sum += n % 10;
n /= 10;
}
n = sum;
}
cout << sum << endl;
}
return 0;
}
杭电OJ 1013 Digital Roots
最新推荐文章于 2021-08-21 22:54:49 发布