竞赛
考级
#include <iostream> using namespace std; int f(int x) { if (x == 0) return 1; return x * f(x - 1); } int main() { int N; cin >> N; cout << f(N) << endl; return 0; }
神-爸爸
#include<iostream> using namespace std; int f(int x){ if(x==0) return 1; return x*f(x-1); } int main(){ int n; cin>>n; cout<<f(n); return 0; } 其实这题并没有很复杂 注解:return 1这一步一定不能少不然会运行错误。PS:个人比较喜欢变量名都设成小写字母
神奇小小猪
提交答案之后,这里将显示提交结果~