← Back to STL Containers
Question 464
Unique Numbers from Input
Unique Numbers from Input
Write a program that reads an integer N from standard input followed by N integers (all separated by whitespace). Insert the N integers into a set<int> and print the distinct values in ascending order on one line, separated by single spaces, followed by a newline (a trailing space after the last value is fine).
Example input:
5
3 1 3 2 1
The output for that input is shown in Expected Output.Expected Output:
1 2 3 5 10 15 20
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
STL ContainersSets
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.