fork(1) download
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4. class compare {
  5. public:
  6. bool operator()(const int &lhs, const int& rhs) const
  7. {
  8. return lhs < rhs;
  9. }
  10.  
  11. };
  12. int main()
  13. {
  14. int arr[]={9,2,5,7,3,5,7,5,4,5,6,4,5};
  15. make_heap(arr,arr+13,compare());
  16. for(auto i:arr)
  17. cout<<i<<" ";
  18. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
9 7 7 5 6 5 5 2 4 5 3 4 5