q.Write a program that contains a function named "remove_duplicates" that takes an array of integers in random order, and then eliminates all the duplicate integers in the array. The function should take three arguments:
- An array of integers which is (read and filled in main)
- The size of the array.
A variable passed by reference to be printed in main to show how many values in the array without duplication. The function should not return a value, but if any duplicate integers are eliminated, then the function should count that, so the new value tells the number of distinct integers in the array. Suppose the array passed to the function is as shown below, and the size of the array passed to the function is 10.
0 1 2 3 4 5 6 7 8 9 58 | 26 | 91 | 26 | 70 | 70 | 91 | 58 | 58 | 66
The function should change the array to look like this:
0 1 2 3 4 5 6 7 8 9
58 | 26 | 91 | 70 | 66 | ?? | ?? | ?? | ?? | ??
and it should change the value of the distinct counter so that it is 5. The question marks in the cells after the 5th cell indicate that it does not matter what numbers are in those cells when the function returns.
something is wrong with my function
void remove_duplicates ( int h[] ,int n ,int &count ){
count = 0;
int a[100];
for (int i = 0 ; i < n ; i++ )
for(int j = i ; j<n ; j++){
if(h[i]!=h[j])
a[i]=h[i];
else
count++;
std::setprobably won't maintain order.