ok i have this activity which i dont know if it's really the correct output on the input ones.
i have this problem making two stacks and two queues.
A.Input stack: used to store all user input
B.input queue: used to store all user input
C.Output stack: used to store data deleted from input queue
D. Output queue: used to store data deleted from input stack
I only have this menu on selecting insert or delete.
i'll just post my main.c
Code:
#include<stdio.h>
#include<stdlib.h>
#include"teststack.h"
void main(){
StackList s1=create();
int choice,item;
do{
do{
printf("Press 1-Insert\n");
printf("Press 2-Delete\n");
printf("Press 3-Exit\n");
printf("Enter choice: ");
scanf("%d", &choice);
if(choice<1 || choice>3)
printf("Invalid input");
}while (choice<1 || choice>3);
switch(choice)
{
case 1:
printf ("Enter number to push: ");
scanf ("%d", &item);
printf("\n====================");
printf("\nInput Stack: \n");
push (s1, item);
display(s1);
printf("\n");
printf("\nInput Queue: \n");
enqueue(s1, item);
display(s1);
printf("====================\n");
break;
case 2:
pop(s1);
push (s1, item);
printf("\n====================");
printf("\nOutput Stack: \n");
display(s1);
printf("\n");
printf("\nOutput Queue: \n");
dequeue(s1);
enqueue(s1, item);
display(s1);
printf("\n");
printf("====================\n");
break;
default:
printf("End.");
}
}while(choice!=3);
}
and this is the output of Input Stacks & Queues.
is this correct?