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