#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int queue[10],front=1,rear=1,ch,val,i;
clrscr();
do{
printf("\n 1.add 2.delete 3.display 4.exit");
scanf("%d",& ch);
if(ch == 1)
{
scanf("%d",& val);
if(front == -1 && rear == -1)
{
front =0;
rear =0;
queue[rear]=val;
}
else
if(rear<9)
{
queue[++rear]=val;
}
else
printf("queue is full");
}
if(ch == 2)
{
if(front<=rear)
{
printf("%d",queue[front++]);
}
else
printf("queue is empty");
}
if(ch == 3)
{
for(i=front;i<=rear;i++)
printf("%d",queue[i]);
}
if(ch == 4)
exit(0);
}while(1)
getch();
}
No comments:
Post a Comment