Homework 1 (Due: Friday, 24th, 11:59 PM)

(Read all instructions before you begin)

Write C++ functions that produce the following patterns.

The first function should have the header (signature) void draw_tree_vertical(int n). It should print the horizontal pattern of a tree of height n. For example, draw_tree_vertical(1) should print:

*

draw_tree_vertical(3) should print

      *
     ***
    *****

draw_tree_vertical(6) should print

      *
     ***
    *****
   *******
  *********
 ***********

The second function should have the header void draw_tree_horizontal(int n). It should print the horizontal pattern of a tree of height n. For example, draw_tree_horizontal(1) should print:

*

draw_tree_horizontal(3) should print

*
**
***
**
*

draw_tree_horizontal(7) should print

*
**
***
****
*****
******
*******
******
*****
****
***
**
*

The second function should have the header void draw_tree_reflection(int n). It should print the pattern of a tree and its reflection of height n. For example, draw_tree_reflection(1) should print:

**

draw_tree_reflection(3) should print

*    *
**  **
******
**  **
*    *      

draw_tree_reflection(7) should print

*            *
**          **
***        ***
****      ****
*****    *****
******  ******
**************
******  ******
*****    *****
****      ****
**        ****
**          **
*            *

Grading

Each function is worth 10 points. 5 points for correctness, 3 points for the number of lines of code, and 2 points for appropriate PRE/POST comments. draw_tree_vertical should have at most 7 lines of code. draw_tree_horizontal should have at most 9 lines of code. draw_tree_reflection should have at most 14 lines of code. None of your functions should have a nested loop.

I provided a function print_char(char c, int n ), it prints character c, n times. Your implementation should be in the file trees.cc in the Assignments folder on inquire. The file has two constants SPACE and STAR, these are the only characters you need to use with print_char.

When you're done upload trees.cc (don't change the name) to inquire. It should have the same main function that it had when you downloaded it. When I run your code I expect it to print out the three types of trees. Make sure you type in your name as it appears on Inquire, it should be in the first comment of the file.