Machine Problem 4, due Apr 8
Part of
the homework for 22C:60 (CS:2630), Spring 2013
|
Background: Consider the following sequence of 4 figures:
1 2 3 4 [] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [] [] [] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [][] [] [] [][] [][] [][] [][] [][] [][] [][] [][]
The numbers above each figure are its order. The dimensions of a figure as a function of its order are:
Order 0 1 2 3 4 5 6 Rows 0 1 2 5 12 29 70 Columns 0 2 4 10 24 58 140
In general, an order n figure is constructed from four order n–1 figures joined by one order n–2 figure, and the height of an n figure is twice the height of an order n–1 figure plus the height of an order n–2 figure. Because we opted to use a two-character wide box as the basic element, the width of each figure is twice its height.
The Assignment: Write a well commented SMAL Hawk program to plot the largest order figure that will fit on the screen, centered on the screen. Your solution should be submitted in the usual way, in a source file called mp4.a by the end of the day on the due date.
Notes: Obviously, you need the screen dimensions to find the center. See Problem 2 on Homework 5 for a discussion of this. Also, obviously, this program requires a recursive routine to plot the object. The parameters to this routine are, at the very least, the order of the figure to be plotted, and some coordinates indicating where to plot it.
You can set the font size in your terminal window very small and then make the window very big before testing your program if you want to see a high-order figure. Of course, get it working first in a small order.