Well, I suggested while because you can have the i increased with every pass. You can have another one, lets say j, that shows the value not ignored. In your case j could show the last value not ingored.
Lets say you start your calculations from a[1]. You have the following:
Code:
int j = 0;
int i = 1;
while (...) {
if (a[i] compare a[j]) {
do_stuff;
j++;
}
i++;
}
First not that at the beggining j == i - 1
a[j] and a[j] will be compared. If you get what you want then j would be increased. In any case i will also be increased. If you don't get what you want then j will not get increased. Isn't that what you want:
Well thinking of it even better the previous value thing seems better:
Code:
for (i = 1; ...; i++) {
if (a[i] compare a[previous]) {
do_stuff;
previous++;
}
}
The same thing actually. Just proposed while as an idea. Gives you the opportunity to think more clearly about what you should do.
Is that what you want?