Advertisement
MohamedAbdel3al

print Equilateral triangle

Aug 21st, 2022
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1.     int rows, coef = 1;
  2.  
  3.     cout << "Enter number of rows: ";
  4.     cin >> rows;
  5.  
  6.     for(int i = 0; i < rows; i++)
  7.     {
  8.         for(int space = 1; space <= rows-i; space++)
  9.             cout <<"  ";
  10.  
  11.         for(int j = 0; j <= i; j++)
  12.         {
  13.             if (j == 0 || i == 0)
  14.                 coef = 1;
  15.             else
  16.                 coef = coef*(i-j+1)/j;
  17.  
  18.             cout << coef << "   ";
  19.         }
  20.         cout << endl;
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement