递归算出来是多少
运行下面这段程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int fact(int n) {
if (n <= 1) return 1;
return n * fact(n - 1);
}
int main() {
cout << fact(5) << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
运行下面这段程序:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int fact(int n) {
if (n <= 1) return 1;
return n * fact(n - 1);
}
int main() {
cout << fact(5) << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)
全部评论