Advertisement
Guest User

Code

a guest
Aug 8th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.     int size = 20; //Change this
  9.     char s = '*'; //Change this
  10.     int e = 2;
  11.  
  12.     for (int i = 0; i < size; i++){
  13.         if ((i + 1) % 2 == 1){ //If "i" is odd
  14.             //Prints blank spaces
  15.             printf("%*c", size - i - e, ' ');
  16.             for (int h = 0; h < i + 1; h++){
  17.                 //Prints stars to form the pyramid
  18.                 printf("%c", s);
  19.             }
  20.             cout << endl;
  21.             e--;
  22.         }
  23.     }
  24.  
  25.     system("PAUSE");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement