#include #include using namespace std; struct node { int dest, cost; node(int d, int c) { dest =d; cost = c; } bool operator < (const node & r) const { return cost > r.cost; } }; int main(void) { priority_queue q; while (1) { int x, y; printf("dest="); scanf("%d", &x); if (x == -1) break; printf("cost="); scanf("%d", &y); q.push(node(x, y)); } printf("queue: \n\n"); while (!q.empty()) { node n = q.top(); printf("{%d, %d}\n", n.dest, n.cost); q.pop(); } system("pause"); return 0; }