1: //is_sorted1a.cpp 3: #include <iostream> 4: #include <iomanip> 5: #include <vector> 6: #include <algorithm> 7: using namespace std; 9: int main() 10: { 11: cout << "\nThis program illustrates the use of the STL " 12: "is_sorted() algorithm from\n<algorithm> to " 13: "test whether a vector of integers is sorted " 14: "in (default)\nascending order."; 15: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 17: int a[] = {1, 2, 3, 4, 5}; 18: int b[] = {1, 2, 3, 6, 5}; 19: vector<int> va(a, a+5); 20: vector<int> vb(b, b+5); 21: cout << boolalpha; 22: cout << is_sorted(va.begin(), va.end()) << endl; 23: cout << is_sorted(vb.begin(), vb.end()) << endl; 24: cout << "Press Enter to continue ... "; cin.ignore(80, '\n'); 25: }