Programming Assignment

A Christmas tree can be designed as a multi-layer solid isosceles triangles such that the top triangle has the smallest side, the side grows larger for the lower triangles. The apex point the a triangle is overlapped with the bottom of the triangle right on the top of it. Finally, a rectangular trunk is right below the last triangle at the bottom. Write a C program to draw a Christmas tree defined as below:

  1. The Christmas tree has "layer" layers of triangles, where "layer" is between 2 and 5 (including).

  2. The side of the top triangles is "side", where "side" is between 3 and 6 (including).

  3. For every two adjacnet triangles, the side of the lower triangle grows "growth" points, where "growth" is between 1 to 5 (including) points.

  4. The width of the trunk is an odd integer "width", where "width" is between 3 and 9 (including).

  5. The height of trunk is "height", where "height" is between 4 and 10 (including).

  6. Use character '#' for the triangle sides and character '@' for the interior points of the triangles.

  7. Use character '|' for the trunk.

The program should read parameters "layer", "side", "growth", "width", and "height" and then draw the Christmas tree.

In this assignment, you must submit two files: the source code of the solution assignment2_dxxxxxxx.c (80%) and a report to explain how you solve the problem and write the program assignment2_dxxxxxxx.pdf (20%), where dxxxxxxx is your student ID. Also, include program comments in the source code. Submit the assignment solution by sending an email to chh@fcu.edu.tw with subject "Programming Assignment #2, dxxxxxxx".

Sample output: