Each problem description includes a "sample program execution" showing a dialog between the user and a program that solves the problem correctly. In each such dialog, text that is underlined corresponds to input provided by the user. Text that is not underlined corresponds to output (including user prompts) produced by the program.
1st Date: 04/21/90 2nd Date: 04/24/90 There are 3 days between 04/21/90 and 04/24/90. 1st Date: 04/24/90 2nd Date: 04/21/90 There are 3 days between 04/21/90 and 04/24/90. 1st Date: 03/10/65 2nd Date: 09/21/99 There are 12613 days between 03/10/65 and 09/21/99. 1st Date: 08/11/85 2nd Date: 08/11/85 There are 0 days between 08/11/85 and 08/11/85. |
Enter number: 7 Digital Root: 7 Enter number: 3452 Digital Root: 5 Enter number: 397 Digital Root: 1 Enter number: 0 Digital Root: 0 |
1st input: 10371 2nd input: 315 Result: 10686 1st input: 54696543201678654789456 2nd input: 82067690004564356875434 Result: 136764233206243011664890 1st input: 0 2nd input: 0 |
A set is a collection of elements, or members. If S and T are sets such that every member of S is also a member of T, then S is said to be a subset of T. (It is possible for each of S and T to be a subset of the other. In this case, they contain precisely the same members.) If S is a subset of T but T is not a subset of S —which is to say that every member of S is also a member of T, but T contains some member that is not a member of S— then S is said to be a proper subset of T.
Given any two sets S and T, they are related to each other —with respect to the subset of concept— in exactly one of four ways:
With every character string x we can associate the set Sx whose members are precisely those characters appearing (at least once) in x. For example, if x is the string "MISSISSIPPI", then Sx is the set whose members are "M", "I", "S", and "P". If x and y are character strings and Sx is a subset of Sy, we say that x is a string-subset of y.
Develop a program that, given as input two character strings x and y, reports (in the manner illustrated below) which of the four possible relationships holds between the sets Sx and Sy. The program should terminate when the user enters as input two empty strings.
Sample Program Execution:
Enter 1st string: MISAPPROPRIATION Enter 2nd string: MISSISSIPPI MISSISSIPPI is a proper string-subset of MISAPPROPRIATION. Enter 1st string: JUNK Enter 2nd string: JACKASS Neither JUNK nor JACKASS is a string-subset of the other. Enter 1st string: BATTLES Enter 2nd string: STABLES Each of BATTLES and STABLES is a string-subset of the other. Enter 1st string: Enter 2nd string: |
Develop a program that, given as input three points P1, P2, and P3 on the cartesian coordinate plane, reports whether P3 lies on the line containing P1 and P2.
In order to input the three points, the user enters six integers x1, y1, x2, y2, x3, and y3. The three points are P1 = (x1, y1), P2 = (x2, y2), and P3 = (x3, y3).
The program should repeat until the user's input is such that P1 and P2 are the same point.
Sample Program Execution:
Enter x1: 12 Enter y1: 5 Enter x2: 7 Enter y2: 9 Enter x3: 10 Enter y3: 7 The point (10,7) IS NOT on the line containing (12,5) and (7,9). |
Enter shift value: 7 Enter message: THE END IS NEAR Encoded message: AOL LUK PZ ULHY Enter shift value: -4 Enter message: ALL ABOARD Encoded message: WHH WXKWNZ Enter shift value: 0 |