题解 | #The Biggest Water
The Biggest Water Problem
https://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4
#include <stdio.h> //函数递归 int DigitSum(int n) { if(n <= 10) return n % 10; //算出位数之和 int sum = (n % 10)+DigitSum(n / 10); //判断位数之和,大于10就重新进行一次位数之和 if(sum > 10) return (sum % 10)+DigitSum(sum / 10); //到这说明位数之和已经小于10了 return sum; } int main() { int n; scanf("%d", &n); int count = DigitSum(n); printf("%d", count); return 0; }