Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<time.h>
- using namespace std;
- int main()
- {
- int NumberOfRows;
- int Spaces;
- int Random;
- bool Please = false;
- srand(time(NULL));
- while(Please == false)
- {
- cout << "Number of rows:" << endl << "> ";
- cin >> NumberOfRows;
- if(NumberOfRows >= 70) cout << "You can't have trees that big." << endl;
- else if (NumberOfRows <= 8) cout <<"You can't have trees that small." << endl;
- else Please = true;
- cout << endl;
- }
- for (int x = 0; x <= NumberOfRows; x++)
- {
- if (x % 2 == 1) Spaces = (NumberOfRows - x - 1)/2;
- else Spaces = (NumberOfRows - x)/2;
- for (int y = 0; y <= Spaces; y++) cout << " ";
- for (int z = 0; z <= x; z++)
- {
- Random = rand() % 7 + 1;
- if (Random != 3) cout << "*";
- else cout << "O";
- }
- cout << endl;
- }
- Spaces = (NumberOfRows - 4)/2;
- for (int k = 0; k <= Spaces; k++) cout << " ";
- cout<<"| |" << endl;
- for (int k = 0; k <= Spaces; k++) cout << " ";
- cout<<"| |" << endl; //What is a for loop?
- system("PAUSE");
- return 0;
- }
- /* Output:
- Number of rows:
- > 40
- *
- **
- ***
- ****
- O***O
- ******
- ******O
- ********
- O******O*
- OO*****O*O
- ****O******
- O*****O*****
- *O*O*********
- *****O*OO*****
- ********O**O**O
- *O*O***O**O*O***
- ******O****O*O**O
- ******O***********
- O*****O************
- *O******************
- ************O********
- *******O**************
- **O*****O***O**********
- ************O*********O*
- ************O***********O
- ***O***O****O*************
- *O*****************OO******
- *************************O*O
- ***************OO***O***O*O**
- *******O***O****************O*
- O*O*O*O****O*******************
- ***OO***********O***************
- **O*******O*******O*******O****O*
- ******OOO*************************
- O****************O*****O***********
- ****O********O****OO********O*******
- *************O***********O********O**
- *******OOO***OO*O*******O*O***O*OO****
- *O*****O************OO***O*******O*****
- O********O*O**********************O*O***
- ***********O***********O*****************
- | |
- | |
- Press any key to continue . . .
- (It looks better than this in a terminal, I promise)
Advertisement
Add Comment
Please, Sign In to add comment