Advertisement
Tavxela

Untitled

Dec 21st, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. void printPyramid(int height) {
  7. char a('*');
  8. for (int i = 0; i < height; i++) {
  9. cout << setw(height - i) << a;
  10. for (int b = 0; b < (i * 2); b++) {
  11. cout << a;
  12. }
  13. cout << a << endl;
  14. }
  15. }
  16.  
  17. int main() {
  18. int input;
  19. cout << "Enter height of pyramid: ";
  20. cin >> input;
  21.  
  22. printPyramid(input);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement