13 solutions
-
0
真的有人要看题解吗?
#include <set> #include <ios> #include <list> #include <cmath> #include <ctime> #include <queue> #include <deque> #include <stack> #include <vector> #include <bitset> #include <cctype> #include <cerrno> #include <cwchar> #include <cstdio> #include <fenv.h> #include <iosfwd> #include <string> #include <limits> #include <math.h> #include <cstdlib> #include <iomanip> #include <clocale> #include <complex> #include <cstring> #include <cstring> #include <cwctype> #include <istream> #include <ostream> #include <sstream> #include <fstream> #include <utility> #include <stdio.h> #include <iostream> #include <stdint.h> #include <string.h> #include <tgmath.h> #include <complex.h> #include <algorithm> #include <exception> #include <stdbool.h> #include <stdexcept> #include <streambuf> #include <functional> #include <inttypes.h> #include <bits/stdc++.h> using namespace std; int main(){ int n,sum = 0; cin >> n; for(int i = 1;i <= n;i++){ sum += i; } cout << sum; return 0; } `
-
-1
对于程序,编译器会对其分配一段内存,在逻辑上可以分为代码段,数据段,堆,栈
代码段:保存程序文本,指令指针EIP就是指向代码段,可读可执行不可写
数据段:保存初始化的全局变量和静态变量,可读可写不可执行
BSS:未初始化的全局变量和静态变量 堆(Heap):动态分配内存,向地址增大的方向增长,可读可写可执行
栈(Stack):存放局部变量,函数参数,当前状态,函数调用信息等,向地址减小的方向增长,非常非常重要,可读可写可执行
如图所示https://www.cnblogs.com/rain-lei/p/3622057.html递归:函数自己调用自己
注意一定要设置好递归终止条件
递归开辟栈空间较大,容易Runtime Error(RE运行时错误,访问超出了指定空间。比如未初始化的变量、数组越界、指针错误等)
https://blog.csdn.net/weixin_44108830/article/details/122010725
- 1
Information
- ID
- 644
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 114
- Accepted
- 61
- Uploaded By