Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Following the advice: Solve the problem with a more appropriate algorithm.Lecture 5 - slide 37 : 39
Program 2
// A more straightforward solution - using the adjent_find algorithm

#include <iostream>
#include <algorithm>
#include <list>

int main(){
  using namespace std;

  list<int> lst;
  lst.push_back(3); lst.push_back(5); lst.push_back(9); lst.push_back(11); 
  lst.push_back(13); lst.push_back(15); lst.push_back(19); lst.push_back(21); 

  if(adjacent_find(lst.begin(), lst.end(), greater<int>()) != lst.end())    // find element out of order
    cout << "The list lst is NOT sorted" << endl;
  else
    cout << "The list lst is sorted" << endl;
}