Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

queue et stack: Ordre Fifo et Lifo


{filelink=15101}

#include <iostream>
#include <string>
#include <queue>
#include <stack>
 
using namespace std;
 
int main()
{
 
	char *str[]={"A", "B", "C", "D"};
   queue<string> q;
 
   cout << "Ordre FIFO avec 'queue':";
   for(int i=0; i<4;i++)
	   q.push(*(str+i));
 
   stack<string> s;
   while (q.size() > 0)
   {
      string lettre = q.front();
      q.pop();
      cout << lettre << " ";
      s.push(lettre);
   }
  cout<<endl;
 
   cout << "Ordre LIFO avec 'stack':";
   while (s.size() > 0)
   {
      cout << s.top() << " ";
      s.pop();
   }
	cout<<endl;
   return 0;
}

No comments yet.

Leave a Comment