< previous page page_834 next page >

Page 834
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Data Structures:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
The problem requires you to maintain two lists, one for men and one for women. The lists must include the following information: name (20 characters), phone number (8 characters), number of interests (maximum number is 10), interests (10 characters each; must be in alphabetical order), and a variable that gives the position of the client's current match (-1 if not matched). When a new client is added to the list, his or her name is added to the bottom of the appropriate list. (You do not keep the names of the clients in alphabetical order.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Input:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Number of current clients
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Sex (M or F), name (20 characters), phone number (8 characters), number of interests, list of interests (10 characters for each one, with no embedded blanks: interests are separated by blanks). There is a record like this for each of the current clients.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
The rest of the file includes data lines that look like one of the following (all the lines start with a 10-character word as outlined below; box.gif indicates a blank):
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
NewClient box.gif sex (M or F), name (20 characters), number of interests, interests (10 characters for each one; see above for description)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
If the keyword NewClient occurs, you should add the client to the appropriate list by storing the required information. Match him or her with a member of the opposite sex. (A match occurs when at least three of the interests are the same. Interests are sorted, which makes the matching process easier. Use an insertion sort to sort interests.) Make sure you then designate both persons matched as described above. Print the name of the new client, his or her match, and both phone numbers. If no match is found, print an appropriate message.
OldClient box.gif name (20 characters)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Unmatch this name from its current match by setting the match variables for the name and its match to -1.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
PrintMatch
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Print a list of all matched pairs.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
PrintNotbox.gifbox.gif
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Print the names and phone numbers of clients who are not currently matched.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
StopProgbox.gifbox.gif
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
This will be the last line in the file.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Output:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Information as described above, printed with appropriate titles.

 
< previous page page_834 next page >