首页 > 代码库 > 数字基root

数字基root

<pre name="code" class="cpp">#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n=0;

    while ( EOF != scanf("%d", &n) )
    {
        
        int temp = n;
        int sum = n;
       do 
       {
           temp = sum ;
           sum =0;
           while (0 != temp)
           {
               sum += temp % 10;
               temp /= 10;
           }
       } while (sum >= 10);
        printf("%d\n", sum);

    }

    return 0;
}


数字基root