home *** CD-ROM | disk | FTP | other *** search
- Problem 6: Count the relationships.
-
- The input file will contain an unknown number of lines each
- having four positive integers. The last line will be
- -1 -1 -1 -1
-
- Do not output anything for the last line; it's there for use
- as a sentinel.
-
- The numbers on each line are guaranteed to be distinct; that is,
- no number will appear more than once in the quartet of numbers.
-
- For each line, count the number of times a smaller number appears
- to the left of a larger number, and also count the number of times
- a larger number appears to the left of a smaller number;
- for example, if the four numbers are
- 7 9 27 23
- the "lessthan" count is 5, because 7<9, 7<27, 7<23, 9<27, 9<23,
- but 27>23; the "greaterthan" count is 1, because 27>23.
-
- Your output should be: the original four numbers followed by
- the lessthan-count and the greaterthan-count all on one line.
-
- Each input line should generate one output line.
-
- For example, your output line for the above input line would be:
- 7 9 27 23 5 1
-
-