Skip to content

Instantly share code, notes, and snippets.

@tanvir002700
Created April 16, 2016 13:33
Show Gist options
  • Save tanvir002700/5be41469a2c705ff7bf25c01b8887298 to your computer and use it in GitHub Desktop.
Save tanvir002700/5be41469a2c705ff7bf25c01b8887298 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<queue>
#include<stdlib.h>
using namespace std;
int main()
{
queue<int>Q;
for(int i=0;i<5;i++)
{
int x=rand()%100;
cout<<"Insert "<<x<<endl;
Q.push(x);
}
cout<<"Q front element: "<<Q.front()<<endl;
Q.pop();
cout<<"Q front after pop: "<<Q.front()<<endl;
cout<<"Queue size: "<<Q.size()<<endl;
while(!Q.empty())Q.pop();
cout<<"Is queue empty: "<<Q.empty()<<endl;
return 0;
}
Insert 83
Insert 86
Insert 77
Insert 15
Insert 93
Q front element: 83
Q front after pop: 86
Queue size: 4
Is queue empty: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment