class Solution { public: int getSum(int n) { int res=n; n>0 && (res+=getSum(n-1)); //条件表达式有一个短路的性质,如果n>0,才会进行下一步的递归操作 return res; } };