题目
July 7, 2021 · View on GitHub
求 1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case 等关键字及条件判断语句 (A?B:C)。
样例
输入:10
输出:55
参考答案
class Solution {
public:
int getSum(int n) {
char a[n][n+1];
return sizeof(a)>>1;
}
};
July 7, 2021 · View on GitHub
求 1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case 等关键字及条件判断语句 (A?B:C)。
样例
输入:10
输出:55
class Solution {
public:
int getSum(int n) {
char a[n][n+1];
return sizeof(a)>>1;
}
};