Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct node
- {
- int data;
- struct node* next;
- }grill;
- grill* fst = NULL;
- grill* rear = NULL;
- void Insert(int);
- void Remove();
- int main()
- {
- Insert(7);
- Insert(10);
- Insert(200);
- Remove();
- printf("%d\n", fst->data);
- printf("%d\n", rear->data);
- system("pause");
- return 0;
- }
- void Insert(int value) /*Insert one list to the last of the Queue*/
- {
- grill* crt;
- crt = (grill*)malloc(sizeof(grill));
- crt->data = value;
- crt->next = NULL;
- if(rear == NULL) /*No data*/
- {
- fst = crt; /*Let crt be the first data*/
- }
- else
- {
- rear->next = crt;
- }
- rear = crt;
- }
- void Remove() /*Remove the first list of the Queue*/
- {
- grill* crt;
- if(fst == NULL)
- {
- printf("Queue is empty!\n");
- }
- else
- {
- crt = fst;
- fst = fst->next; /*Let crt point to fst, and make fst point to the next list*/
- }
- free(crt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement