Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int** pascal(int n){
  6.  
  7. int coef = 1;
  8.  
  9. for(int i = 0; i < n; i++)
  10. {
  11. for(int space = 1; space <= n-i; space++)
  12. cout <<" ";
  13.  
  14. for(int j = 0; j <= i; j++)
  15. {
  16. if (j == 0 || i == 0)
  17. coef = 1;
  18. else
  19. coef = coef*(i-j+1)/j;
  20.  
  21. cout << coef << " ";
  22. }
  23. cout << endl;
  24. }
  25.  
  26. return 0;
  27. }
  28.  
  29. int main(){
  30.  
  31. int rows;
  32. cout << "Enter number of rows: ";
  33. cin >> rows;
  34.  
  35. pascal(rows);
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement