数字基root

时间:2014-12-31 14:35:38   收藏:0   阅读:257
<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;
}


原文:http://blog.csdn.net/xiaohanstu/article/details/42293909

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!