Hi, I got a problem with removing duplicate ints from an array.
Problem is that user will type ints as many as he or she can.
The program need to print out unsorted list of numbers after removing duplicates.
eg. user type: 2 4 2 8 4 8
Then need to print out like this: 2 4 8
This my code but it doesn't work correctly it either removes last integers or adds random values.
cout<< numbs[0] << " ";
for (int i = 1; i < n; i++)
{
bool matching = false;
for (int j = 0; (j < i) && (matching == false); j++)if (numbs[i] == numbs[j]) matching = true;
if (!matching) cout<< numbs[i] << " ";
}
The first number is printed out because it doesn't act before.
In the first loop you should check all number from 1 till n:
for (int i = 1; i < n; i++)
Variable matching is used for storing the matching under checking process.
In the next loop you should check that the checked number acted before. If it is true than it will be noted in variable matching.