Hello guys,
So my task is the following:
Draw a pine tree based on user inputted height.
How tall should the tree be?: 6
/\
/ \
/ \
/ \
/ \
/ \
------------
||
||
||
I had problems moving the cursor from the left to right in order to draw the backlash characters, however, I managed to do some of it, but they do not align in the way they should. I would appreciate any help, here is my code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main ()
{
int height;
cout << "Please enter a height for the tree: " << endl;
cin >> height;
for (int level = 0; level < height; level++)
{
for (int spaces = 0; spaces < height - level - 1; spaces++)
cout << ' ';
for (int a = 0; a < 2 - 1; a++)
cout << '/' << endl;
for (int middle = 0; middle < 2 * level + height; middle++)
cout << ' ';
for (int b = 0; b < 2 - 1; b++)
cout << '\\'<< endl;
}
return 0;
}