求C(n,k)的方法很多,这里只介绍打表的方法. 递推式:C(n,k) = C(n-1,k-1) + C(n-1,k) 代码: #include <iostream> using namespace std; const int MAX = 100; int c[MAX][MAX]; int main() { int i,j; for(i=1; i<=1000; ++i) { c[i][0] = 1; c[i][1] = i; } for(i=2; i<=1000; ++i) for(j=2; j<=i; ++j) c[i][j] = (c[i-1][j-1]+c[i-1][j]); int n,k; while(cin >> n >> k) { cout << c[n][k] << endl; } return 0; }