#include<iostream>
#include<string>
using namespace std;
int main()
{
int i,n;
string s;
while (cin>>s&&s != "0")
{
n = 0;
for (i=0;i < s.length(); i++)
{
n += s[i] -'0';
}
int temp;
while(n / 10 != 0)
{
temp = 0;
while(n)
{
temp += n % 10;
n = n / 10;
}
n = temp;
}
cout<<n<<endl;
}
return 0;
}
hdu 1013 Digital Roots
最新推荐文章于 2020-07-04 17:53:28 发布