Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n, k, comb[100][100];
- int main() {
- puts("Combinari de n luate cate k:");
- cin >> n >> k;
- for (int i = 0; i <= n; i++) {
- for (int j = 0; j <= k; j++) {
- if (i == j)
- comb[i][j] = 1;
- else if (i < j)
- comb[i][j] = 0;
- else
- comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
- }
- }
- cout << comb[n][k] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement