問題詳情

以下程式會算出 C(N, M),即從 N 個物品中選出 M 個物品的方法數量。如果 count 的值原先為 0,請問計算 C(5, 3) 後,count 的值為何?unsigned int count = 0;unsigned int getC(unsigned int N, unsigned int M){count++;if (N == 0) return (N == M ? 1 : 0);else if (M == 0) return 1;else return getC(N-1, M) + getC(N-1, M-1);}
(A) 5
(B) 15
(C) 51
(D) 63

參考答案

答案:C
難度:困難0.349206
統計:A(7),B(30),C(44),D(19),E(1)

內容推薦

內容推薦