作者avogau ( 假 装)
看板TransCSI
标题Re: [问题] 高雄大学95计概3,4 96计概4,6,8
时间Tue Jun 30 18:29:40 2009
※ 引述《katsuoli (katsuo)》之铭言:
: 8.Let C(n, k) denote the number of ways to select k out of n items without
: order. It is known that
: C(n ,1) = n, C(n, n) = 1, and C(n, k) = C(n-1, k-1)+C(n-1, k). Please write a
: recursive function
: comb(int n, int k) that computes C(n ,k) based on the above-mentioned
: knowledge
: 这也看不懂,好像是排列组合问题?
: 问题很多,麻烦各位了。
int comb(int n, int k)
{
if( n== k or k == 0 ) return 1;
return comb(n-1, k-1)+comb(n-1, k);
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.168.97.210