fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. int rows;
  7. // Getting the number of rows.
  8. cout << "Enter the Number of rows - ";
  9. cin >> rows;
  10.  
  11. cout << "Full Pyramid of " << rows << " using * -\n";
  12.  
  13. // Main logic to print full pyramid.
  14. for( int i = 0; i < rows; i++ ) {
  15. // Print spaces.
  16. int spaces = rows - i;
  17.  
  18. for( int j = 0; j < spaces; j++){
  19. cout <<" ";
  20. }
  21.  
  22. // Print stars.
  23. for( int j = 0; j < 2 * i - 1; j++){
  24. cout <<"* ";
  25. }
  26.  
  27. cout << endl;
  28.  
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5276KB
stdin
6
stdout
Enter the Number of rows - Full Pyramid of 6 using * -
            
          * 
        * * * 
      * * * * * 
    * * * * * * * 
  * * * * * * * * *