--- title: S1A 數字和 tags: solution --- # A. 數字和 - 本題源自於Online Judge(UVa):[11332 - Summing Digits](https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2307) ```cpp= #include <iostream> using namespace std; long f(long x){ long sum1=0; while(x > 0) { sum1 += x%10; x /= 10; } return sum1; } int main() { long num; while (cin >> num && num != 0) { while ((num = f(num))>=10); cout << num << "\n"; } } ```