CS102 Fall 2020 MT2 - Duplicates
Write a program that reads in a sequence of up to 250 numbers and indicates if each number is duplicated at least once. The user will start by entering an integer, n
, (0 <= n <= 250) and then proceed to enter n
integers. We have declared an array large enough to hold 250 numbers in the skeleton code. Use only the portion of the array necessary.
Your output should be the message: All numbers have duplicates
if they all do, or Numbers with no duplicate: k
where k is the count of how many numbers did not have at least one duplicate (i.e. appeared only once in the input sequence).
5
1 2 1 2 2
Should generate the output:
All numbers have duplicates
Input:
4
4 2 1 2
Should generate the output:
Numbers with no duplicate: 2
Since 4
and 1
only appear once (have no duplicate) in the input sequence.
The skeleton file can be downloaded with the link: duplicates.cpp.
(You may need to right-click and choose Save As or Save Target As to download the .cpp
file or open it in your browser and save the file.).