首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

9度教程第42题

2013-02-18 
九度教程第42题题目地址:http://ac.jobdu.com/problem.php?cid1040&pid41C语言源码:#includestdio.hin

九度教程第42题

题目地址:http://ac.jobdu.com/problem.php?cid=1040&pid=41

C语言源码:

#include<stdio.h>int root(int n){int num=0;while(n){num+=n%10;n/=10;}return num;}int main(){int n,i;char s[1000];scanf("%s",s);getchar();while(s[0]!='0'){i=0;n=0;while(s[i]!='\0')n+=s[i++]-'0';while(n>=10)n=root(n);printf("%d\n",n);scanf("%s",s);getchar();}}



热点排行