Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

5

7

20

8

-7

15

3

8

14

7

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago