Here is my code so far:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
struct rev
{
char category[100],name[35];
int ID;
struct rev* next;
};
}
struct rev* newNode(int ID,const char *category,const char *name)
{
struct rev* new_node = (struct rev*)malloc(sizeof(struct rev));
strcpy(new_node->category,cateogyr);
strcpy(new_node->name,name);
new_node->ID=ID;
new_node->next=NULL;
return new_node;
}
I don't understand exactly what I'm suppose to do.I have tried to implement a list,but I don't know if it has to have just the category.
CodePudding user response:
You are asked to implement a list of queues. Each node in the list will represent a category and will have a field that is a queue of the ticket reservations. Here are what the operations should do:
- Adding a category will add a node in the list, the corresponding queue will be empty
- Adding a ticket request will iterate over the list, find the node with the given category and enque in the corresponding queue
- Serving a ticket request will iterate over the list, find the node with the given category and deque in the corresponding queue
- Will have to print the list (here it is not clear what is the desired format).
CodePudding user response:
You can use c STL List Library and like vector-tuple you can create your own linkedlist structure(of category type) and implement another structure(of type queue inside) your category type linked list structure and maintain linked list rules of traversing and whenever you want to perform operations on queue just first use traversing of linked list and get on the node and then use queue operation...
