1: //is_heap2a.cpp
3: #include <iostream>
4: #include <iomanip>
5: #include <vector>
6: #include <algorithm>
7: #include <functional>
8: using namespace std;
10: int main()
11: {
12: cout << "\nThis program illustrates the use of the STL "
13: "is_heap() algorithm from\n<algorithm> and the "
14: "greater<int>() functor from <functional> to test"
15: "\nwhether a vector of integers is a minimum heap.";
16: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
18: int a[] = {3, 8, 5, 9, 12, 14, 6, 17, 15};
19: int b[] = {3, 8, 5, 9, 6, 14, 12, 17, 15};
20: vector<int> va(a, a+9);
21: vector<int> vb(b, b+9);
22: cout << boolalpha;
23: cout << is_heap(va.begin(), va.end(), greater<int>()) << endl;
24: cout << is_heap(vb.begin(), vb.end(), greater<int>()) << endl;
25: cout << "Press Enter to continue ... "; cin.ignore(80, '\n');
26: }