// A more straightforward solution - using the adjent_find algorithm #include #include #include int main(){ using namespace std; list lst{3, 15, 9, 11, 13, 15, 21}; if(adjacent_find(lst.begin(), lst.end(), greater{}) != lst.end()) // find a pair of elements out of order. cout << "The list lst is NOT sorted" << endl; // greater is shown in the next program. else cout << "The list lst is sorted" << endl; }