hi im making an exercise about two arrays. one is a working like a stuck (LIFO-Last in First Out)array and the second one like a queue (FIFO-First IN First Out). The problem is that im confused what to write in the case 3 and 4.....:?:
Any additional help about compiler syntax errors would be nc.
Thanks in advance....
#include <stdio.h>
#include <stdlib.h>
#define N 10
#define N2 12
int push(int stuck[N],int head,int item,int flag,int N);
int pop(int stuck[N],int head,int item,int flag);
int engueue(int Q[N2],int rear,int item,int flag,int front,int N2);
int dequeue(int Q[N2],int front,int rear,int item,int flag);
int N,stuck[N],N2,Q[N2];
int main()
{
int sel,flag,item,head=0,front,rear;
do
{
do
printf("1.Push\n");
printf("2.Pop\n");
printf("3.Degueue\n");
printf("4.Enqueue\n");
printf("5.EXIT\n");
scanf("%d",&sel);
while (sel>0) && (sel<6);
switch (sel)
{
case 1:{
printf("Dwse to item\n");
scanf("&d",&item);
push(stuck,head,item,flag);
if (flag==0)
printf("Stoiva pliris\n");
}
case 2:{
pop(stuck,head,item,flag);
if (flag==0)
printf("Stoiva adia\n");
else
writeln("%d",item);
}
case 3:{
printf("Dwse to item\n");
scanf("&d",&item);
engueue(Q,rear,item,flag,front,N2);
if (flag==0)
printf("Oura pliris\n");
}
case 4:{
dequeue(Q,front,rear,item,flag);
if (flag==0)
printf("Oura adia\n");
else
writeln("%d",item);
}
}
}
while (sel!=5);
system("pause");
return 0;
}
int push(int stuck,int head,int item,int flag,int N)
{
if (head<(N-1))
{
head+=1;
stuck[head]=item;
flag=1;
}
else
flag=0;
return flag,head;
}
int pop(int stuck,int head,int item,int flag);
{
if (head>0)
{
item=stuck[head];
head-=1;
flag=1;
}
else
flag=0;
return item,flag,head;
}
int engueue(int Q,int rear,int item,int flag,int front,int N);
{
if (front==0)
front=1;
if (rear<=(N2-1))
{
rear+=1;
Q[rear]=item;
flag=1;
}
else
flag=0;
return flag;
}
int dequeue(int Q,int front,int rear,int item,int flag);
{
if (front!=0)
{
item=Q[front];
front+=1;
flag=1;
if(front>rear)
{
rear=0;
front=0;
}
}
else
flag=0;
return flag,item;
}