/*#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*#include<stdio.h>
int arr[101]= {},array[101][101]= {},i,j=0,c,k,s=0;
void f(int z)
{
int p;
for(p=1; p<=c; p++)
{
if(array[z][p]==1)
{
array[z][p]=0;
array[p][z]=0;
arr[p]=1;
f(p);
}
}
}
int main()
{
int x, y;
scanf("%d %d",&c,&k);
for(i=0; i<k; i++)
{
scanf("%d %d", &x, &y);
array[x][y] = 1;
array[y][x] = 1;
}
f(1);
for(i=1; i<=c; i++)
{
if(arr[i]==1)
{
j++;
}
}
printf("%d",j-arr[1]);
return 0;
}*/
#include<stdio.h>
#define MAXSIZE 5
int queue[MAXSIZE] = {};
int front = 0, rear = 0;
void push(int k) {
if(front==MAXSIZE && rear == 0) {
printf("QUEUE is Full\n");
return;
}
if(front==MAXSIZE&&rear!=0)
{
queue[0]=queue[front-rear];
queue[front-rear]=0;
for(int i=1;i<=front-rear;i++)
{
queue[i]=queue[front-rear+i];
queue[front-rear+i]=0;
}
front = rear;
rear = 0;
}
queue[front++] = k;
}
void pop() {
if(rear == front) {
printf("QUEUE is Empty\n");
return;
}
printf("Output data is %d\n", queue[rear]);
queue[rear] = 0;
rear++;
}
void view() {
printf("Q list\n");
for(int i=0; i<MAXSIZE; i++) {
printf("%d\n", queue[i]);
}
printf("--------------\n");
}
int main() {
int n, k;
for(;;) {
printf("1: push, 2:pop, 3:view\n");
scanf("%d", &n);
switch(n) {
case 1:
printf("input data is: ");
scanf("%d", &k);
push(k);
break;
case 2:
pop();
break;
case 3:
view();
break;
default:
printf("ERORORRRRROR\n");
break;
}
}
}



