Write a (nonrecursive) function
void showH(void)
that prints the
moveto and rlineto (or lineto)
commands needed to draw only one large H.
Write your main function so that it prints out the PostScript
header information, then calls showH, then prints
out the final showpage command.
This will give you confidence
that your program is producing valid PostScript.
As a second step, expand your showH() function so
that it now takes three
arguments x, y, and size of
type double.
Write your function so that it draws an H,
centered at PostScript coordinate (x,y), and with each
of the 3 line segments having length size.
You will probably want to use exactly this showH()
function in your final program.
To debug and test your function, modify main() so
that it calls showH() a few times, with different
parameters.
Write a recursive function recur() that
takes one int argument n, prints the value
n,
and then calls itself four times with the value n-1.
The recursion should stop when n becomes 0.
To test this function out,
write main() so that it reads one integer
n from standard input using scanf(),
and calls recur() with that value.
You should get the
following output.
Make sure you understand how this function works, and why it
prints the numbers in the order it does.
As second step, modify recur() so
that instead of printing n, it prints the size
of the H to be plotted. The first call to recur()
is from main(), and it plots the big H.
Each line segment of the big H has
length 256.0, so print 256.0. Each successive level of recursion
will halve the length. Your function should produce the
following output.