class Solution { public: int Sum_Solution(int n) { int ans = n; //ans为0的时候 &&后面是不计算的 ans && (ans += Sum_Solution(n - 1)); return ans; } };
【剑指offer47 求1+...+n】
原文:https://www.cnblogs.com/Stephen-Jixing/p/13137556.html