题解 | #The Biggest Water Problem#

The Biggest Water Problem

http://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4


int sum(int a)
{
	int b;
	for (b = 0; a != 0;)
	{
		b += a % 10;
		a /= 10;
	}
	return b;
}

int main()
{
	int a = 0;
	int b = 0;

	scanf("%d", &a);

	b = sum(a);
	while (b> 9)
	{
		b = sum(b);
	}

	printf("%d\n", b);
	return 0;
}
全部评论

相关推荐

11-07 13:31
怀化学院 Java
勇敢牛牛不怕难:又疯一个
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务