#include <algorithm>
#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char **argv) {
  int heap[10];

  for(int i=0; i<10; i++) {
    heap[i] = rand()%100;
  }

  for(int i=0; i<10; i++) {
    cout << heap[i] << " ";
  }
  cout << endl;

  make_heap(heap, heap+10);

  /*  for(int i=0; i<10; i++) {
    cout << heap[i] << " ";
  }
  cout << endl; */

  for(int n=10; n>0; n--) {
    for(int i=0; i<10; i++)
      cout << heap[i] << ' ';

    pop_heap(heap, heap+n);
    cout << '\n';
  }


  return 0;
}
