← Back to STL Containers
Question 472
Tally a multiset
Tally a multiset
Amultiset<int>namedmsalready holds the values 2, 5, 2, 8, 5, 2. Print each distinct value exactly once, in ascending order, one per line, in the form: the value, a space, the letter x, and the number of copies (no space between x and the number). Every line ends with a newline, including the last one.
Expected Output:
2 x3 5 x2 8 x1
= 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.