C++
用递归函数求,m的阶乘除以n的阶乘除以m-n的阶乘有没有C语言大佬,拜托拜托 (哈哈哈这是什么复合帖,在JAVA区用C++标题问C语言问题)
应该是用递归求阶乘吧,整体用递归好像没有必要 确实把我逗笑了
^_^
#include <stdio.h>
unsigned long long foo(unsigned long long m)
{
if(m > 1LL) return m * foo(m - 1LL) ;
else return 1LL ;
}
int main(void)
{
unsigned long long m , n ;
printf("enter m & n : ") ;
scanf("%llu%llu" , & m , & n) ;
if(m > n && n > 0) printf("%llu\n\n" , foo(m) / foo(n) / foo(m - n)) ;
else printf("Error : the m must greater then n !\n\n") ;
}
编译、运行实况:
D:\\>g++ -o x x.c
D:\\>x
enter m & n : 6 3
20
D:\\> {:10_256:}
页:
[1]