This PROGRAM SHOULD BE IN C++ NO JAVA IN THIS PROGRAM AT ALL Write a queue-based
ID: 3677916 • Letter: T
Question
This PROGRAM SHOULD BE IN C++
NO JAVA IN THIS PROGRAM AT ALL
Write a queue-based linked list application that allows the user to enter a list of positive integers (up to 25), possibly with duplicates in the linked list. Your application should enqueue the integers in the order specified by the user, removing any duplicates, and allow the user to enter 0 or a negative integer to quit entering integers. Then, print out the queue resulting from head to tail
Explanation / Answer
#include #include #include using namespace std; struct node { int data; node *next; }*front = NULL,*rear = NULL,*p = NULL,*np = NULL; void push(int x) { np = new node; np->data = x; np->next = NULL; if(front == NULL) { front = rear = np; rear->next = NULL; } else { rear->next = np; rear = np; rear->next = NULL; } } int remove() { int x; if(front == NULL) { coutnext; delete(p); return(x); } } int main() { int n,c = 0,x; coutn; while (cRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.