Advertisement
AlexandruDu

Coeficienti binomali

Dec 21st, 2020
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int n, k, comb[100][100];
  4.  
  5. int main() {
  6.     puts("Combinari de n luate cate k:");
  7.     cin >> n >> k;
  8.     for (int i = 0; i <= n; i++) {
  9.         for (int j = 0; j <= k; j++) {
  10.             if (i == j)
  11.                 comb[i][j] = 1;
  12.             else if (i < j)
  13.                 comb[i][j] = 0;
  14.             else
  15.                 comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
  16.         }
  17.     }
  18.     cout << comb[n][k] << endl;
  19.     return 0;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement