1: //sort_heap1a.cpp 3: #include <iostream> 4: #include <vector> 5: #include <algorithm> 6: using namespace std; 8: int main() 9: { 10: cout << "\nThis program illustrates the use of the STL sort_heap() " 11: "algorithm (default\nversion) to sort a (maximum) heap of " 12: "integers into ascending order."; 13: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 15: int a[] = {100, 19, 36, 17, 3, 25, 1, 2, 7}; 16: vector<int> v(a, a+9); 18: cout << "\nHere are the values in the heap:\n"; 19: for (vector<int>::size_type i=0; i<v.size(); i++) 20: cout << v.at(i) << " "; 21: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 23: cout << "\nNow we sort these values into ascending order."; 24: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 25: sort_heap(v.begin(), v.end()); 27: cout << "\nHere is the result:\n"; 28: for (vector<int>::size_type i=0; i<v.size(); i++) 29: cout << v.at(i) << " "; 30: cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n'); 31: }