posts - 17,  comments - 0,  trackbacks - 0
 1 #include <cstdlib>
 2 #include <iostream>
 3 
 4 using namespace std;
 5 
 6 int main(int argc, char *argv[])
 7 {
 8     int n,a,b;
 9     while(scanf("%d",&n)&&!(n==0))
10     {
11         
12         do
13         {   a=0;
14             while(n!=0)
15             {
16                 a+=n%10;
17                 n/=10;               
18             }                       
19             n=a;
20             
21         }while(a/10!=0);
22         printf("%d\n",a);
23     }
24 
25 
26     system("PAUSE");
27     return EXIT_SUCCESS;
28 }
29 
posted on 2011-11-16 22:33 刘聪 阅读(165) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(4)

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜