一共压了几层
运行下面这段程序,它数的是「递归压了几层」:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int depth = 0;
void down(int n) {
depth++;
if (n == 0) return;
down(n - 1);
}
int main() {
down(2);
cout << depth << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论