Курсовая работа: Списки стеки очереди в C
case 2 :
if (! isEmpty(headPtr)) {
item = dequeue(&headPtr, &tailPtr);
printf("%c has been dequeued.\n" , item);
}
printQueue(headPtr);
break;
default:
printf ("Invalid choice.\n\n"); instructions(); break; }
printf ("?"); scanf("%d", &choice); }
printf("End of run.\n");
return 0;
}
void instructions(void)
{printf ("Enter your choice:\n"
" 1 to add an item to the queue\n"
" 2 to remove an item from the queue\n" " 3 to end\n"); }
void enqueue(QUEUENODEPTR *headPtr, QUEUENODEPTR *tailPtr,char value) {
QUEUENODEPTR newPtr;
newPtr =new QUEUENODE;
if (newPtr != NULL) { newPtr->data = value; newPtr->nextPtr = NULL;
if (isEmpty(*headPtr))
*headPtr = newPtr; else
(*tailPtr)->nextPtr = newPtr;
*tailPtr = newPtr; } else
printf("%c not inserted. No memory available.\n", value);
}
char dequeue(QUEUENODEPTR *headPtr, QUEUENODEPTR *tailPtr) {
char value;