next up previous
Next: 2 A Simple Spread Up: APS105F Friday Quiz 2 Previous: Instructions

1 Printing Words

You are to complete a program that reads in a number of words as strings, such as a sentence, and then outputs the words in different orders. There are two procedures, called ForwardPrint and ReversePrint, that do the printing. Each procedure takes three parameters. The last parameter is the array of strings. The first two parameters indicate the part of the string array to print, i.e., print the strings from Strings(StartIndex) to Strings(EndIndex) or in reverse, depending on the procedure.

What to do

Copy the file ``/usr/copy/aps105/revstring.t'' into your working directory and rename it ``part1.t''. A listing of this file is given in Appendix A starting on page gif.

Complete the two procedures ForwardPrint and ReversePrint. You are to write ForwardPrint as a recursive procedure and ReversePrint using a loop in the procedure.

Assumptions

Assume that only legal inputs are entered.

Restrictions

You should only write the code for the procedures. Do not change any other part of the program when you submit your solution, though you are free to make modifications while testing. Just make sure that the program you submit has the original code.

Example Input Sequence

An example of the input sequence is:

Input String, end with `end' 
Be careful driving elephants in small flimsy garages. end

A Solution

Go here to see a solution.



Paul Chow
Sun Nov 24 16:01:05 EST 1996