Question
Write a C++ program (or Java program) called hw1_2.cpp (or hw1_2.java) that reads two groups of numbers in which each group has several integer numbers
Write a C++ program (or Java program) called hw1_2.cpp (or hw1_2.java) that reads two groups of numbers in which each group has several integer numbers without duplicates. Your program should display the non-common numbers in both groups in descending order.
Input format: This is a sample input from a user.
|
The first number (= 5 in the example) indicates that there are five numbers in the first group. Then, the numbers from the second line (= 7 in the example) to the sixth line (15 in the example) are actual numbers of the first group.
The following number (= 3 in the example) indicates that there are three numbers in the second group which are 8, 14, and 7.
For the input, your program should present the non-common numbers in both groups in descending order. Note that both 7 and 8 are common numbers in the two groups. Thus, you have to display the non-common numbers (= 20, 15, 14, -7) in descending order on the screen. If theres a non-common number, your program should display NONE.
Sample Run 0: Assume that the user typed the following lines.
5
7
20
8
-7
15
3
8
14
7
This is the correct output of your program.
Answer:20 15 14 -7
Sample Run 1: Assume that the user typed the following lines.
3
5
-5
0
3
-5
0
5
This is the correct output of your program.
Answer:NONE
Sample Run 2: Assume that the user typed the following lines.
5
3
-5
4
2
7
4
2
7
4
-5
This is the correct output of your program.
Answer:3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started