please I need your help inthis program because I do not under stand what does he want and I didn't under stand the array so please help me


Write a function named "eliminate_duplicates" that takes an array of integers in random order and eliminates all the duplicate integers in the array. The function should take two arguments:
(1) an array of integers;
(2) an integer that tells the number of cells in the array.
The function should not return a value, but if any duplicate integers are eliminated, then the function should change the value of the argument that was passed to it so that the new value tells the number of distinct integers in the array. Here is an example. Suppose the array passed to the function is as shown below, and the integer passed as an argument to the function is 11.
Index 0 1 2 3 4 5 6 7 8 9 10
Array 58 26 91 26 70 91 70 58 58 66 58

Then the function should alter the array so that it looks like this:
Index 0 1 2 3 4 5 6 7 8 9 10
Array 58 26 91 70 66 ?? ?? ?? ?? ?? ??

and it should change the value of the argument so that it is 5 instead of 11 . 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.
thank you

What part of it are you having trouble with? And don't say all of it, because I'll stop helping if you act like you want us to give you solutions without any effort on your part.

(2) an integer that tells the number of cells in the array.

but if any duplicate integers are eliminated, then the function should change the value of the argument that was passed to it so that the new value tells the number of distinct integers in the array.
thank you

:!: :!: :!:

looks to me as if you did! I suggest picking up a text book or changing course!!

what do you mean??!!!!!!!

(2) an integer that tells the number of cells in the array.

but if any duplicate integers are eliminated, then the function should change the value of the argument that was passed to it so that the new value tells the number of distinct integers in the array.
thank you

Pass a pointer. Or if this is C++, a reference:

void remove_duplicates ( int array[], int *size );
void remove_duplicates ( int array[], int& size );

This way you can change the value of size, and the change will be reflected in the calling function.

thanks but would you explain more i did not understand sorrrrrrrrrrrrrrry

>thanks but would you explain more i did not understand sorrrrrrrrrrrrrrry
Book. Read. Experiment. Try. I can sympathize with you, I really can. But unless you show that you're making an attempt to do this, it makes me feel like I'm wasting my time. Instead of saying you don't understand and asking for clarification, try to work through figuring it out and tell me your thought process. That way I can direct you to how things really work instead of just giving you the answers.

this is my try but it did not work

#include <iostream>
using namespace std;


int main()
{
int SIZE=10;
int a[10];
cout<<"enter numbers"<<"\n";
int i,j;
for(i=0;i<SIZE;i++)
cin>>a;
for(i=0;i<SIZE;i++)
for(j=i+1;j<SIZE;j++)
if(a==a[j])
a[j]='\0';
a[j]=a[j+1];
SIZE=SIZE-1;


cout<<a <<endl;


return 0;
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

#include <iostream>
#include <iterator>

using namespace std;

void remove_item ( int index, int array[], int& size )
{
  for ( int i = index; i < size - 1; i++ )
    array[i] = array[i + 1];
  --size;
}

void remove_dup ( int index, int array[], int& size )
{
  for ( int i = index + 1; i < size; i += array[i] != array[index] ) {
    if ( array[i] == array[index] )
      remove_item ( i, array, size );
  }
}

void remove_duplicates ( int array[], int& size )
{
  for ( int i = 0; i < size; i++ )
    remove_dup ( i, array, size );
}

int main()
{
  int a[] = {58, 26, 91, 26, 70, 91, 70, 58, 58, 66, 58};
  int size = 11;

  copy ( a, a + size, ostream_iterator<int> ( cout, " " ) );
  cout<<endl;

  remove_duplicates ( a, size );

  copy ( a, a + size, ostream_iterator<int> ( cout, " " ) );
  cout<<endl;
}

>ostream_iterator<int>
>what does it use for
To be perfectly frank, you aren't quite at a level where even a simple explanation of stream iterators would make sense. Concentrate on remove_duplicates, not how I printed the array. You can do the same thing with this:

for ( int i = 0; i < size; i++ )
  cout<< a[i] <<' ';
cout<<endl;
This article has been dead for over six months. Start a new discussion instead.