题解 | #求1+2+3+...+n#
求1+2+3+...+n
https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1
#include <regex> class Sum { public: Sum() { _ret+=_i; ++_i; } static int GetRet() { return _ret; } private: static int _i; static int _ret; }; int Sum:: _i = 1; int Sum:: _ret = 0; class Solution { public: int Sum_Solution(int n) { Sum arr[n]; return Sum::GetRet(); } };