写一个递归算法和一个迭代算法计算二项式系数:/m!(n-m)!
正确性高点!
人气:425 ℃ 时间:2020-03-28 17:49:32
解答
int jiecheng(int z)
{
if(z>=0)
{if(z==0)
return 1;
else if(z==1)
return 1
else
return z*jiecheng(z-1);
}
else
return -1;
}
int binconf(int x,int y)
{
if(x>y)
return jiecheng(x)/(jiecheng(y)*jiecheng(x-y));
else
return -1;
}
没测试过,不知对不对
推荐
猜你喜欢
- 是一个和谐的大家庭用英语怎样翻译?
- Don't regard me as a fool!
- on bamboo slips 怎么读
- 勉励刻苦读书的四字词语(4个);含比喻意义的四字词语(四个)
- what will we stay there
- She looks ______than she is.A.the more older B.very older C.much older D.more older
- 从1,2,3,4,5,6,7,8,9,10这10个数中任意抽取3个数,其中至少有两个数是连续整数的概率是?
- 一个圆的面积与一个正方形的面积相等,那么这个圆的周长一定( )这个正方形的周长