Example #1
0
File: main.cpp Project: CCJY/coliru
int main()
{
    std::string a("abc");
    auto it = make_reverse(a.end());
    
    while ( it != a.rbegin() )
        std::cout << *it++ ;
}
  void nextPermutation(std::vector<int> &array)
  {
    int idx = array.size() - 1;
    int last_idx = idx;
    while (idx > 0 && array[idx - 1] >= array[idx]) {
        idx -= 1;
    }

    if (idx <= 0) {
      make_reverse(array, 0, last_idx);  
      return; 
    }

    int r_idx = last_idx;
    while (array[idx - 1] >= array[r_idx]) {
        r_idx -= 1;
    }
    std::swap( array[idx - 1], array[r_idx]);
  
    make_reverse(array, idx, last_idx);  
  }