Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- struct Coord
- {
- int x, y, cost;
- bool operator < (const Coord &v) const
- {
- return cost > v.cost;
- }
- };
- priority_queue <Coord> q;
- int main()
- {
- int i;
- Coord v;
- for(i = 1; i <= 10; i++)
- {
- v.x = i;
- v.y = 2 * i;
- v.cost = (i * i) % 13;
- q.push(v);
- }
- while(!q.empty())
- {
- v = q.top();
- q.pop();
- cout << v.x << " " << v.y << " " << v.cost << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment