fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. struct st
  4. {
  5. int a;
  6. int b;
  7. int c;
  8. };
  9. bool operator>(st a,st b)
  10. {
  11. return a.a>b.a;
  12. }
  13. int main()
  14. {
  15. st x,y;
  16. x.a=1,x.b=3,x.c=5;
  17. y.a=3,y.b=4,y.c=1;
  18. priority_queue<st,vector<st>,greater<st>> pq;
  19. pq.push(x);
  20. pq.push(y);
  21. while (!pq.empty())
  22. {
  23. st v=pq.top();
  24. cout<<v.a<<endl;
  25. pq.pop();
  26. }
  27.  
  28. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1
3