|
|
 |
|
|
|
|
Data Structures: |
|
|
|
 |
|
|
|
|
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.) |
|
|
|
 |
|
|
|
|
Input: |
|
|
|
 |
|
|
|
|
Number of current clients |
|
|
|
 |
|
|
|
|
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. |
|
|
|
 |
|
|
|
|
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; indicates a blank): |
|
|
|
 |
|
|
|
|
NewClient sex (M or F), name (20 characters), number of interests, interests (10 characters for each one; see above for description) |
|
|
|
 |
|
|
|
|
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 name (20 characters) |
|
|
|
 |
|
|
|
|
Unmatch this name from its current match by setting the match variables for the name and its match to -1. |
|
|
|
 |
|
|
|
|
PrintMatch |
|
|
|
 |
|
|
|
|
Print a list of all matched pairs. |
|
|
|
 |
|
|
|
|
Print the names and phone numbers of clients who are not currently matched. |
|
|
|
 |
|
|
|
|
This will be the last line in the file. |
|
|
|
 |
|
|
|
|
Output: |
|
|
|
 |
|
|
|
|
Information as described above, printed with appropriate titles. |
|
|
|
|
|