fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int space, rows;
  7.  
  8. cout <<"Enter number of rows: \n";
  9. cin >> rows;
  10. cout << endl;
  11. for(int i = 1, k = 0; i <= rows; ++i, k = 0)
  12. {
  13. for(space = 1; space <= rows-i; ++space)
  14. {
  15. cout <<" ";
  16. }
  17.  
  18. while(k != 2*i-1)
  19. {
  20. cout << "* ";
  21. ++k;
  22. }
  23. cout << endl;
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 15232KB
stdin
5
stdout
Enter number of rows: 

        * 
      * * * 
    * * * * * 
  * * * * * * * 
* * * * * * * * *