正儿八经递归写法,一看就会,清晰明了
The Biggest Water Problem
https://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4
#include <stdio.h> int fun(long long n) { int sum=0; while(n) { sum+=n%10; n/=10; } if(sum>9) { sum=fun(sum); } return sum; } int main() { long long n=0; scanf("%lld",&n); printf("%d\n",fun(n)); return 0; }