So my program is just reading an input of numbers and lists them in order. As seen in the output. Without the use of the algorithm library, I sorted it and getting rid of repeated data. However, if there is a data value repeated, the last value of the vector is not printed. Am I incorrectly using the .erase?
void remove_repeated(int size, vector<int>& num_vec){
for(int i = 0; i < num_vec.size(); i++){
if(num_vec[i]==num_vec[i+1]){
num_vec.erase((num_vec.begin()+i));
}
}
}
Output when no value is repeated:
**Welcome to the HW Reading Program**
Please, enter your HW:1-10
Do Problems: 1, 2, 3, 4, 5, 6, 7, 8, 9,and 10
Output when a value is repeated:
**Welcome to the HW Reading Program**
Please, enter your HW: 1-10,1-3
Do Problems: 1, 2, 3, 4, 5, 6, 7, 8,and 9