
Originally Posted by
wael.salman
what do you mean by:
First you write code that just iterates through the whole array and copies each array number to itself using the two indexes.????
Like this,
Code:
int w=0; // write index
int r=0; // read index
while (r < array_size) {
array[w++] = array[r]; // copy number, increment write index by 1
r++; // increment read index by 1
}
The array and array_size are defined elsewhere.
The above just copies the array on itself. You modify it so the r index is incremented in each iteration to skip a whole sequence of equal numbers. The w index is incremented as before. The effect is that only one number of any equal number sequence is copied.