you could tune the codes to make it become safer, faster and generic
as your need, if there are bugs, please tell me, I will try my best to
fix it

[CODE]
size_t remove_adjacent(size_t first, size_t *last, std::vector &result)
{
if(first == last) return 0;

size_t next = first + 1;
if(next == last) result.push_back(
first);
while(next != last)
{
if(first <= next)
{
std::cout<<first<<", "<<next<<std::endl;

  result.push_back(*first);
  ++first; ++next;
  if(next == last)
  result.push_back(*first);
}
else if(*first > *next)
{
  std::cout<<*first<<", "<<*next<<std::endl;
  result.push_back(*first);
  if(last - next > 1)
  {
    first += 2;
    next  += 2;
  }
  else
  {
    return last;
  }
}

}
}

void case_03()
{
size_t A[] = { 1, 2, 3, 4, 2, 1, 6, 9 };
std::vector result;
remove_adjacent(A, A + sizeof(A) / sizeof(*A), result);
std::copy(result.begin(), result.end(), std::ostream_iterator(std::cout, "\n") );
}
[/CODE]

Stefano Mtangoo commented: Why would you do his work? Why??? -3
WaltP commented: That would be good. Then he doesn't have to do the project himself and he can pass his class on YOUR work. -4