Advertisement
AlexandruT

Priority queue #1

Jul 6th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3.  
  4. using namespace std;
  5. priority_queue <int> q;
  6.  
  7. int main()
  8. {
  9.     for(int i = 1; i <= 10; i++)
  10.         q.push(i * i % 13);
  11.     while(!q.empty())
  12.     {
  13.         cout << q.top() << " "; // afiseaza elementul maxim din q
  14.         q.pop(); // sterge din q elementul maxim
  15.     }
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement