#include #include #include "QueueInterface.h" #include #include "StackInterface.h" void PrintQueue( Queue *Q) { QueueNode *L; L=Q->Front; printf("displaying the queue:\n"); while (L != NULL) { printf("%c\n", L->Item); L = L->RLink; } printf("end of queue\n"); return; } int main(void) { char Line[80]; ItemType Element; Queue Q; int Counter; Stack S; InitializeStack(&S); InitializeQueue(&Q); printf ("please enter line for analysis>"); gets(Line); /*put line in a queue */ for (Counter == 0; Line[Counter] != '\0'; Counter++) { Insert(Line[Counter], &Q); } PrintQueue( &Q); /*push elements of this queue in a stack */ while ( !EmptyQ(&Q) ) { Remove(&Element, &Q); Push(Element, &S); } /* insert elements from the stack back into empty queue */ while ( !Empty(&S) ) { Pop(&Element, &S); Insert(Element , &Q); } PrintQueue( &Q); return 0; }