There is an array with 9 spaces(elements), where those 9 numbers will be stored which are entered by user.
How would you make sure that they enter only those 9 numbers and that they are not the same?
Finally cout(print) them from less to greater?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a solution that ensures numbers in the range [0,9], and ignores duplicates:
First Method: (better for a wider range)
Second Method: (better for a 0-9 range)
The key here is
std::set, which only allows unique entries, and automatically sorts the elements.