组合数打表及快速求组合数
组合数打表
#include <bits/stdc++.h>
using namespace std;
int C[1005][1005];
int main()
{
C[0][0] = 1;
for (int i = 1; i <= 1000; i++)
{
C[i][0] = 1;
for (int j = 1; j <= 1000; j++)
C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
}
cout << C[4][3] << endl;
return 0;
}
快速求组合数
#include <bits/stdc++.h>
using namespace std;
int C[1005][1005];
int main()
{
C[0][0] = 1;
for (int i = 1; i <= 1000; i++)
{
C[i][0] = 1;
for (int j = 1; j <= 1000; j++)
C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
}
cout << C[4][3] << endl;
return 0;
}