C++简单代码/符合题意/3行:
class Solution {
public:
int Sum_Solution(int n) {
n && (n += Sum_Solution(n - 1)); //A&&B 1.A为true,则计算并返回表达式B的bool值
return n; //2.A为false,则直接返回false
}
};
C++简单代码/符合题意/3行:
class Solution {
public:
int Sum_Solution(int n) {
n && (n += Sum_Solution(n - 1)); //A&&B 1.A为true,则计算并返回表达式B的bool值
return n; //2.A为false,则直接返回false
}
};