CSC 235
Programming Assignment #8
Fall 2011
Due Date: 11/4/2011

The following are two problems from a recent ACM Programming Contest. While the contest allows teams to use C, C++, or Java, you must solve the problem in C++. Also, the teams have three contestants who work together, you should work alone. On the other hand, the teams have 5 hours to solve as many problems as they can out of the nine problems given. You will have over a week to solve just two problems, and these are the easy problems. You should design your solution and create a test data set that will test your program as much as you can. When you think that you have a correct solution, email your source code to me. I will compile and run your program using my own test data. There will be no hardcopy turned in to me.


Gnome Sequencing

Source file: gnome.cpp
Input file: gnome.in

In the book All Creatures of Mythology, gnomes are kind, bearded creatures, while goblins tend to be bossy and simple-minded. The goblins like to harass the gnomes by making them line up in groups of three, ordered by the length of their beards. The gnomes, being of different physical heights, vary their arrangements to confuse the goblins. Therefore, the goblins must actually measure the beards in centimeters to see if everyone is lined up in order.

Your task is to write a program to assist the goblins in determining whether or not the gnomes are lined up properly, either from shortest to longest beard or from longest to shortest.

Input: The input starts with line containing a single integer N, 0 < N < 30, which is the number of groups to process. Following this are N lines, each containing three distinct positive integers less than 100.

Output: There is a title line, then one line per set of beard lengths. See the sample output for capitalization and punctuation.

Example Input: Example Output:
3
40 62 77
88 62 77
91 33 18
Gnomes:
Ordered
Unordered
Ordered



Duplicate Removal

Source file: dup.cpp
Input file: dup.in

The company Al's Chocolate Mangos has a web site where visitors can guess how many chocolate covered mangos are in a virtual jar. Visitors type in a guess between 1 and 99 and then click on a "Submit" button. Unfortunately, the response time from the server is often long, and visitors get impatient and click "Submit" several times in a row. This generates many duplicate requests.

Your task is to write a program to assist the staff at ACM in filtering out these duplicate requests.

Input: The input consists of a series of lines, one for each web session. The first integer on a line is N, 0 < N ≤ 25, which is the number of guesses on this line. These guesses are all between 1 and 99, inclusive. The value N = 0 indicates the end of all the input.

Output: For each input data set, output a single line with the guesses in the original order, but with consecutive duplicates removed. Conclude each output line with the dollar sign character '$'. Note that there is a single space between the last integer and the dollar sign.

Example Input: Example Output:
5 1 22 22 22 3
4 98 76 20 76
6 19 19 35 86 86 86
1 7
0
1 22 3 $
98 76 20 76 $
19 35 86 $
7 $