mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 13:58:48 +00:00
84. 求1+2+…+n
https://www.acwing.com/problem/content/submission/code_detail/14064231/
This commit is contained in:
parent
f491e2fc25
commit
af3743ba87
8
AcWing/84/84.cpp
Normal file
8
AcWing/84/84.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
class Solution {
|
||||
public:
|
||||
int getSum(int n) {
|
||||
int r = n;
|
||||
n && (r += getSum(n - 1));
|
||||
return r;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user