Abdulg

Epic Christmas Tree Generator (YoloSwag) [C++]

Dec 28th, 2013
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int NumberOfRows;
  9.     int Spaces;
  10.     int Random;
  11.     bool Please = false;
  12.     srand(time(NULL));
  13.     while(Please == false)
  14.     {
  15.         cout << "Number of rows:" << endl << "> ";
  16.         cin >> NumberOfRows;
  17.  
  18.         if(NumberOfRows >= 70) cout << "You can't have trees that big." << endl;
  19.         else if (NumberOfRows <= 8) cout <<"You can't have trees that small." << endl;
  20.         else Please = true;
  21.         cout << endl;
  22.     }
  23.  
  24.     for (int x = 0; x <= NumberOfRows; x++)
  25.     {
  26.         if (x % 2 == 1) Spaces = (NumberOfRows - x - 1)/2;
  27.         else Spaces = (NumberOfRows - x)/2;
  28.        
  29.         for (int y = 0; y <= Spaces; y++) cout << " ";
  30.         for (int z = 0; z <= x; z++)
  31.         {
  32.             Random = rand() % 7 + 1;
  33.             if (Random != 3) cout << "*";
  34.             else cout << "O";
  35.         }
  36.         cout << endl;
  37.     }
  38.     Spaces = (NumberOfRows - 4)/2;
  39.     for (int k = 0; k <= Spaces; k++) cout << " ";
  40.     cout<<"|  |" << endl;
  41.     for (int k = 0; k <= Spaces; k++) cout << " ";
  42.     cout<<"|  |" << endl; //What is a for loop?
  43.     system("PAUSE");
  44.     return 0;
  45. }
  46.  
  47. /* Output:
  48.  
  49. Number of rows:
  50. > 40
  51.  
  52.                      *
  53.                     **
  54.                     ***
  55.                    ****
  56.                    O***O
  57.                   ******
  58.                   ******O
  59.                  ********
  60.                  O******O*
  61.                 OO*****O*O
  62.                 ****O******
  63.                O*****O*****
  64.                *O*O*********
  65.               *****O*OO*****
  66.               ********O**O**O
  67.              *O*O***O**O*O***
  68.              ******O****O*O**O
  69.             ******O***********
  70.             O*****O************
  71.            *O******************
  72.            ************O********
  73.           *******O**************
  74.           **O*****O***O**********
  75.          ************O*********O*
  76.          ************O***********O
  77.         ***O***O****O*************
  78.         *O*****************OO******
  79.        *************************O*O
  80.        ***************OO***O***O*O**
  81.       *******O***O****************O*
  82.       O*O*O*O****O*******************
  83.      ***OO***********O***************
  84.      **O*******O*******O*******O****O*
  85.     ******OOO*************************
  86.     O****************O*****O***********
  87.    ****O********O****OO********O*******
  88.    *************O***********O********O**
  89.   *******OOO***OO*O*******O*O***O*OO****
  90.   *O*****O************OO***O*******O*****
  91.  O********O*O**********************O*O***
  92.  ***********O***********O*****************
  93.                    |  |
  94.                    |  |
  95. Press any key to continue . . .
  96.  
  97. (It looks better than this in a terminal, I promise)
Advertisement
Add Comment
Please, Sign In to add comment