After sheer frustration with this homework problem, I finally created a c++ account. Yes, it is indeed a homework problem and I'm not asking for the solution, but some type of solution. I've tried searching this forum for a hint, but wasn't much helpful.
The hw question is:
Write a full program that reads in an arbitrary sequence of integers from the standard input, and writes them to the standard output in sorted order and with all duplicates removed. You may assume the input contains at most 100 integers.
I think understand what to do on the later half, but I'm specifically getting stumped on "reads in an arbitrary sequence of integers from the standard input."
I'm thinking this has to be an array, but usually dealt with sequences with a set number of integers. Is there a way I can read of 'i' of some random input in array[i] before declaring what i is? I'm assuming no, cause I believe when you're declaring an array in the first place you'll have to set the max number of elements or you'll run into overloading issues.
In all, if there is a way I can figure out the number of elements from the arbitrary sequence, I think the next step would be easier. Thinking of transferring to another array with conditional statements (I think it's called bubble sort, not too worried about the efficiency of the program).
You may assume the input contains at most 100 integers.
With that assumption, you can easily define your array to be big enough to handle all the input without needing to know specifically how many items there are.
for that loop how can I make it stop when there are no more input variables?
You'll have to give the user some way to tell you that they're done inputting values. The simplest way might be to have a "sentinel" value mark the end of input. Something like "Input -1 when finished".
I got it work accepting the inputs, but the output was wrong.
Might be a problem with your sorting algorithm.
But tackle one problem at a time. Don't worry about sorting for now. Just get it accepting input. Once you have that working, then worry about sorting it.