Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void pattern(int stars, int spaces)
  6. {
  7.     if(stars == 0)
  8.         return;
  9.    
  10.     pattern(stars/2, spaces);
  11.  
  12.     for(int i = 0; i < spaces; i++)
  13.     {
  14.         cout << " ";
  15.     }
  16.     for(int i = 0; i < stars; i++)
  17.     {
  18.         cout << "*";
  19.     }
  20.    
  21.     cout << endl;
  22.  
  23.     pattern(stars/2, spaces+stars/2);
  24. }
  25.  
  26. int main()
  27. {
  28.     pattern(8, 0);
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement