#include <set>
#include <iostream>
int main()
{
std::multiset<int> msi;
int no {};
do {
std::cout << "Enter a number between 1 - 1000 (0 to exit): ";
std::cin >> no;
} while (no > 0 && *msi.insert(no));
for (constauto& n : msi)
std::cout << n << ' ';
std::cout << '\n';
}
Be careful if you turn that in. Most schools want you to struggle and fight to build your own solution to things the language can do for you in a couple of lines. This is a combined effect of outdated material, outdated professors (not always, but often), a desire for you to understand how to solve problems (what if you did not have a tool that did it for you, not all languages will have rich tools) and other such things. Even if your professor accepts this code, you will be called on to explain how it works and what a mulitset is, so you at the minimum need to study each line an be able to explain how it works and what it does. In doing so, you should also pick up on what you would need to do if you rolled out your own solution without multiset, so if asked to do it again without you should be able to visualize what needs to happen and recreate it.
If you turn it in and can't explain what a mulitset is or how it works, you will be given a bad score at best; some places may even treat it as cheating (most cheating at universities is marked only for major projects and tests, not often the homework which is just practice for tests and projects but they will still frown on just copying an answer you do not understand).
here is a way to do it using just an array:
unsigned int counts[1001]{}; // an array of 0 to 1000 inclusive set to all zeros.
now if you read in the value 42, you can do
counts[42]++;
after reading in all the values and doing the above increment to the appropriate array location,
a simple for loop puts it back out in order:
for(int i = 0; i < 1001; i++)
if(counts[i]) //did you have any of this value
//print it out, probably a loop of 0 to counts[i] cout i so if you had 23 42's in the data it would print 42 23 times, then check 43, 44, ... 1000...