Question: Write a program sameelements.cpp that takes in two sequences of positive integers and checks whether they have the same elements in some order, now taking
-
Write a program sameelements.cpp that takes in two sequences of positive integers and checks whether they have the same elements in some order, now taking duplicates into consideration. For example, the two sequences
1 4 9 16 9 7 4 9 11
and
would be considered identical. But
1 4 9 16 9 7 4 9 11
and
would not. You may consider typing up one or more functions to help organize things. Assume the user inputs at least one positive integer for each sequence. Hints:
-
You may want to do
cin.clear(); string discard; cin >> discard;
before reading input for the second sequence of numbers. Can you explain why? See Special Topic 4.1 in Section 4.5 (or slide 22 of the Chapter 4 lecture slides).
-
If the two sequences of numbers do NOT have the same length, then they are automatically different.
-
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
