// Print a tree!
#include <iostream>
using namespace std;
int main()
{
int height;
// Height of tree
cout << "Enter height of tree: ";
cin >> height; // Get height from user
// Print stars for each row
for(int row = 0; row < height; row++)
{
// Draw one row for every unit of height
// Print leading spaces
for(int count = 0; count < height - row; count++ )
cout << " ";
// Print out stars, twice the current row plus one:
// 1. number of stars on left side of tree = current row value
// 2. exactly one star in the center of tree
// 3. number of stars on right side of tree = current row value
for(int count = 0; count < 2*row + 1; count++)
cout << "*";
cout << endl;
}
return 0;
}