C++ 计算n的阶乘 (1~10) - 代码示例
#include\u003ciostream\u003e using namespace std;
int factorial(int n) { if (n == 0) { return 1; } else { return n * factorial(n - 1); } }
int main() { int n; cin >> n; cout << factorial(n) << endl; return 0; }
原文地址: https://www.cveoy.top/t/topic/pPP4 著作权归作者所有。请勿转载和采集!