题解 | #求1+2+3+...+n#

求1+2+3+...+n

https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1


static int count = 0;

class sum 
{
public:
    sum()
    {
        _count += _i;
        ++_i;
    }

    static int Getcount()
    {
        return _count;
    }

private:
    static int _i;
    static int _count;
};

int sum::_i = 1;
int sum::_count = 0;

class Solution {
public:
    int Sum_Solution(int n) 
    {
        sum arr[n];
        return sum::Getcount();
    }
};

全部评论

相关推荐

昨天 16:00
门头沟学院 Java
点赞 评论 收藏
分享
码农索隆:这种hr,建议全中国推广
点赞 评论 收藏
分享
06-18 13:28
已编辑
门头沟学院 Web前端
爱睡觉的冰箱哥:《给予你300的工资》,阴的没边了
点赞 评论 收藏
分享
_mos_:我以为手抄报简历就已经很顶了,没想到还有表格简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务