News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Put string into a queue

Started by aruljothi, Jun 11, 2009, 07:21 PM

Previous topic - Next topic

aruljothi

#include <iostream>
#include <string>
#include <queue>
#include <stack>

using namespace std;

int main()
{
   cout << "FIFO order:\n";

   queue<string> q;
   q.push("A");
   q.push("B");
   q.push("C");

   stack<string> s;
   while (q.size() > 0)
   {
      string name = q.front();
      q.pop();
      cout << name << "\n";
      s.push(name);
   }

   cout << "LIFO order:\n";

   while (s.size() > 0)
   {
      cout << s.top() << "\n";
      s.pop();
   }

   return 0;
}