题解 | #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;
}