Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C++: Exemple de suppression des élément de la ‘priority_queue’


{filelink=15090}

 
#include <iostream>
#include <queue>
using namespace std;
 
int main()
{
  int tab[] = {10, 20, 30, 40, 50, 50, 26};
  priority_queue<int> pq;
  cout << "La taille initiale de la 'priority_queue'= " << pq.size() << endl;
 
  /* Ajout des éléments dans la queue*/
  for (int i = 0; i < 7; ++i)
    pq.push(tab[i]);
 
  cout << "Après l'ajout, la taille  de la 'priority_queue'=  " << pq.size() << endl;
 
  cout << "Supprimer 4 éléments de la 'priority_queue' " << endl;
  for (i = 0; i < 4; ++i) {
    pq.pop();
  }
  cout << "La taille après la suppression: " << pq.size() << endl;
 
  return 0;
}

No comments yet.

Leave a Comment