求1+2+3+...+n 发表于 2020-02-08 更新于 2020-02-12 求1+2+3+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 移位、sizeof数组 123456class Solution {public: int Sum_Solution(int n) { return sizeof(bool[n][n + 1]) >> 1; }};