051.二项式系数递归
【摘要】
#include <stdlib.h>#include <stdio.h>#include <conio.h>int binom (int n, int i);void main (void) { int int1;int int2;//´òÓ¡Á½Ïîʽ printf ("NOT...
-
#include <stdlib.h>
-
#include <stdio.h>
-
#include <conio.h>
-
int binom (int n, int i);
-
void main (void)
-
{
-
int int1;
-
int int2;
-
//´òÓ¡Á½Ïîʽ
-
printf ("NOTE: Entering a figure other than a number will \ncause the program to crash.");
-
printf ("\n");
-
printf ("Formula computation is in B(n,i) N, 1st integer >= 2nd, I, Integer.\n\n");
-
printf (" n!\n");
-
printf (" B(n,i)= ----------\n");
-
printf ("k!(n-i)!\n\n");
-
printf ("Warning: Program has no error checking!\n\n");
-
printf ("\nEnter an integer :");
-
scanf ("%d", &int1);
-
printf ("\n");
-
printf ("Enter a second integer :");
-
scanf ("%d", &int2);
-
printf ("\n");
-
printf ("Binomial Coefficiant : %d", binom (int1, int2));
-
getch();
-
}
-
-
int binom (int n, int i)
-
{
-
int n1;
-
int n2;
-
if (( i ==0 ) || (n== i))
-
{
-
return 1;
-
}
-
else
-
{
-
n1 = binom ( n - 1, i);
-
n2 = binom ( n - 1, i -1);
-
return n1 + n2;
-
}
-
}
文章来源: blog.csdn.net,作者:程序员编程指南,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/weixin_41055260/article/details/124492157
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)