提供另一种循环输入判定退出条件的做法, 可以利用逗号表达式的值为最后的表达式的值的性质
#include <bits/stdc++.h> using i64 = long long; signed main() { i64 ans = 0, t; while ((std::cin >> t, t) != 0) ans += (t > 0) * t; std::cout << ans << "\n"; }