SHARE
TWEET

christmass tree

a guest Dec 19th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6.   int n;
  7.   cout << "How big do you want your tree?(up to 18)";
  8.   cin >> n;
  9.   int spaces = 20;
  10.   int stars = 1;
  11.  
  12.   for(int i = 1; i <= n; i++){
  13.  
  14.    for(int a = 1; a <= spaces; a++){
  15.      cout << " ";
  16.    }
  17.    for(int b = 1; b <= stars; b++){
  18.      cout << "*";
  19.    }
  20.    cout << "\n";
  21.    spaces -= 1;
  22.    stars += 2;
  23.   }
  24.  
  25.   spaces = 19;
  26.   stars = 3;
  27.   for(int i = 1; i <= n; i++){
  28.  
  29.    for(int a = 1; a <= spaces; a++){
  30.      cout << " ";
  31.    }
  32.    for(int b = 1; b <= stars; b++){
  33.      cout << "*";
  34.    }
  35.    cout << "\n";
  36.    spaces -= 1;
  37.    stars += 2;
  38.   }
  39.   spaces = 18;
  40.   stars = 5;
  41.  
  42.   for(int i = 1; i <= n + 1; i++){
  43.  
  44.    for(int a = 1; a <= spaces; a++){
  45.      cout << " ";
  46.    }
  47.    for(int b = 1; b <= stars; b++){
  48.      cout << "*";
  49.    }
  50.    cout << "\n";
  51.    spaces -= 1;
  52.    stars += 2;
  53.   }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top