Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

queue: Ajouter et supprimer des élément dans la file

 list, list
{filelink=15099}

 
#include <iostream>
#include <queue>
#include
<list>
using namespace std;
 
int main()
{
 
  int tab[] = {10, 5, 6, 2, 52, 89, 32};
  queue<int, list<int> > q_r;
  cout << "La taille initiale de la file: " << q_r.size() << endl;
 
  cout << "Insertion des éléments du tableau dans la file: " << endl;
  for (int i = 0; i < 7; ++i)
    q_r.push(tab[i]); //Ajout à la fin de la file
 
  cout << "Taille de la file après l'insertion: " << q_r.size() << endl;
 
  cout << "Servir 3 éléments de la file " << endl;
  for (i = 0; i < 3; ++i) {
    cout << q_r.front() << endl;
    q_r.pop();
  }
  cout << "La nouvelle taille de la file:  " << q_r.size() << endl;
 
  return 0;
}
 
 /* 
 
 */

No comments yet.

Leave a Comment