Advertisement
rotti321

Triunghiul lui Pascal

Oct 22nd, 2021
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int Comb(int n, int k){
  6. int p=1;
  7. for(int i=1;i<=n-k;i++){
  8. p=p*(k+i)/i;
  9. }
  10. return p;
  11. }
  12.  
  13. int main() {
  14. int n,k;
  15. cin >> n;
  16. for(int N=0;N<=n;N++){
  17. for(int i=0;i<=N;i++){
  18. cout << Comb(N,i) << " ";
  19. }
  20. cout << endl;
  21. }
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement