← Back to STL Containers
Question 468
Remove Duplicate Words
Remove Duplicate Words
Write a program that reads words from standard input until the input ends (usewhile (cin >> word); the words may be spread over several lines). Store the words in aset<string>, then print each distinct word on its own line in alphabetical order. All words are lowercase letters only. Example input: banana apple banana The output for that input is shown in Expected Output.
Expected Output:
apple banana bird cat dog
= 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.