You can find quality tech news,tricks,study materials etc contact me:facebook.com/ashwin.sunilkumar
Support Me...........
Please support me by giving donation
contact: aswinavofficial@gmail.com
Total Pageviews
Monday, September 1, 2014
C++ program to implement Queue
// Implementation of Queue
#include
using namespace std;
static int front, rear, size;
static int q[100];
void pop();
void push(int n);
void showQueue();
void push(int n) {
if (rear==(size-1)){
cout << "Queue full." << endl;
} else if ((front==-1) &&
(rear == -1)){
front = rear = 0;
q[front] = n;
} else {
q[++rear] = n;
}
showQueue();
}
void pop() {
if (rear==-1 && front==-1)
cout << "Queue empty." << endl;
else if
(front==rear && front!=-1)
front = rear = -1;
else
for (int i=0; i> choice;
switch(choice)
{
case 1:
{
cout << "Enter number to add: ";
int n; cin >> n;
push(n);
break;
}
case 2:
{
pop();
break;
}
case 3:
{
exit = 1;
break;
}
default: break;
}
}
}
// aiuto
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment