If its {1,2,2,3,4} it should be {1,2,3,4}. I just can't figure out how to fix my code to do that. The values are random from 1 to 8. I had thought if I counted how many occurrences of a certain number then I could change the value of it if it was greater than 1.
void duplicate(vector<int> &v)
{
vector <int> num(8);
vector <int> count(8,0);
vector <int> index;
vector <int> temp;
int k = 0;
for(int i = 0; i < index.size(); i++)
{
for(int j = v.size() - 1; j > 0; j--)
{
while(index.at(i) == v.at(j))
{
if(index.at(i) == v.at(j))
{
v.at(j) = 0;
}
}
if(index.at(i)+1 == v.at(j))
{
v.at(j) = 0;
}
}
}
for(int i = 0; i < v.size(); i++)
{
cout << v.at(i);
}
}