#include <iostream>
#include <algorithm>
#include <iterator>
using namespace std;


void reverse(int * from, int * to) {
  while ((to - from) > 1) {
    --to;
    int temp = *from;
    *from = *to;
    *to = temp;
    ++from;
  }
}

int const * find(int const * from,
                 int const * const to,
                 int const value) {
  while ((from != to) && (*from != value)) {
    ++from;
  }
  return from;
}

void reverse_until (int * const from,
                                  int * const to,
                                  int const sentinel) {
  int const * const position_sentinel = find(from, to, sentinel);
  reverse(from, from + (position_sentinel - from));
}


int main() {
  int test[10];
  for (size_t i = 0; i < 10; ++i) {
    test [i] = i + 1;
  }
  reverse_until (test, test + 10, 6);
  copy(test, test + 10, ostream_iterator<int>{cout, " "});
  return 0;
}