c语言 函数与递归

/*函数和递归 
自定义函数:返回类型 函数名(参数列表){函数体   return 0;}
无返回值类型  比如只是向屏幕输出一些内容 只需定义返回值类型为void
定义结构体 typedef struct{double x ,y;}类型名字; */ 
#include <stdio.h>


long long factorial(int m, int n)
{
long long ans = 1;
if(m < n-m) m = n-m;
for(int i = m+1; i <= n; i++) ans *= i;
for(int j = 1; j <= n - m; j++) ans /= j;
return ans;
 
}


int main()
{
int m, n;
long long count = 0;
scanf("%d %d", &m, &n);
count = factorial(m, n);
printf("%I64d", count);
return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_38663663/article/details/79664907