# include <iostream>
using namespace std;
int fact(int n)
{
if(n == 1 || n == 0)
{
return 1;
}
return n * fact(n - 1);
}
int main()
{
int m, k, j;
cin>>m>>k;
j = fact(m)/(fact(k) * fact(m - k));
cout<<j;
return 0;
}
高效来算阶乘就用递归函数
int fact(int n)
{
return n * fact (n - 1);
}
不要再用函数里面编写函数了哈哈哈。
博客介绍了使用C++递归函数高效计算阶乘的方法,给出了计算阶乘的递归函数代码,同时提醒不要在函数里编写函数。
710

被折叠的 条评论
为什么被折叠?



