#include #include #include using namespace std; class Judge{ public: Judge(int i, long double d) { id = i; distance = d; } bool operator <(const Judge & other) { return distance > other.distance; } void Tell() { cout << id << " " << distance; } private: int id; long double distance; }; int main() { vector people; srand(time(nullptr)); for (int i=0;i<10;i++) { people.push_back(Judge(i,rand()%20)); } make_heap(people.begin(), people.end()); while (people.size() > 0) { people.front().Tell(); cout << endl; pop_heap(people.begin(), people.end()); people.pop_back(); } }