当前位置:网站首页>【JZ64 求1+2+3+...+n】
【JZ64 求1+2+3+...+n】
2022-07-30 10:37:00 【爱吃榴莲的喵星人】
一、题目描述
二、题目代码
提示:内部类实现
class Solution {
private:
class Sum
{
public:
Sum()
{
_ret += _i;
_i++;
}
};
static int _ret;
static int _i;
public:
int Sum_Solution(int n) {
Sum arr[n];
return _ret;
}
};
int Solution::_ret = 0;
int Solution::_i = 1;
class Sum
{
public:
Sum()
{
_ret += _i;
_i++;
}
static int get_ret()
{
return _ret;
}
private:
static int _ret;
static int _i;
};
int Sum::_ret = 0;
int Sum::_i = 1;
class Solution {
public:
int Sum_Solution(int n) {
Sum arr[n];
return Sum::get_ret();
}
};
以上是本篇文章的全部内容,如果文章有错误或者有看不懂的地方,多和喵博主交流。互相学习互相进步。如果这篇文章对你有帮助,可以给喵博主一个关注,你们的支持是我最大的动力。
边栏推荐
- VLAN实验
- spark udf 接受并处理 null值.
- Oracle中SQL语言和分页rownum分析
- Re19: Read the paper Paragraph-level Rationale Extraction through Regularization: A case study on European Court
- 分页 paging
- jmeter接口压力测试(一)
- OC - Manual Reference Counting Memory Management
- MFCC转音频,效果不要太逗>V<!
- Js array operating mobile for encapsulation
- 神经网络学习笔记3——LSTM长短期记忆网络
猜你喜欢

Easy gene: human tRNA gene loci showed age-related high DNA methylation | research articles

自适应控制——仿真实验一 用李雅普诺夫稳定性理论设计自适应规律

易基因:人类tRNA基因位点表现出与衰老相关的DNA高甲基化|研究文章

从数据流中快速查找中位数

flowable workflow all business concepts

Linux内核设计与实现(十)| 页高速缓存和页回写

VLAN实验

实现web实时消息推送的7种方案

死锁的理解

(***Key points***) Flink common memory problems and tuning guide (1)
随机推荐
OC-关于alloc和dealloc(还没开始写)
基于.NetCore开发博客项目 StarBlog - (16) 一些新功能 (监控/统计/配置/初始化)
数据库脏读、不可重复读、幻读以及对应的隔离级别
Shell system learning function
OC- about alloc and dealloc (haven't started writing yet)
Neural Network Study Notes 3 - LSTM Long Short-Term Memory Network
R语言怎么绘图(一个r语言完整的命令有什么)
关于verilog的时延研究
Log4j有哪几种日志级别呢?
电压跟随器不要随便加
Meikle Studio - see the actual combat notes of Hongmeng device development 4 - kernel development
(***Key points***) Flink common memory problems and tuning guide (1)
Selected System Design | Design of CAN Bus Controller Based on FPGA (with Code)
mysql分页查询倒序_【Mysql笔记】MySQL实现分页查询[通俗易懂]
oracle export dmp file type as "crash dump file"
类和对象—6个默认成员函数
Swift 常用扩展类和简单封装
【梦想起航】
log4j中appender的简介说明
spark udf accepts and handles null values.
