Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- typedef struct QUEUE
- {
- int info;
- struct QUEUE *next;
- }queue;
- void insert(queue **q, int item)
- {
- // q - указатель на очередь или указатель на next
- //последнего ненулевого элемента.
- while ((elem = ∗q) != NULL)
- q = &elem->next;
- elem = malloc(sizeof(∗elem));
- if (elem) {
- elem->info = item;
- elem->next = NULL;
- ∗q = elem;
- }
- }
- int main()
- {
- queue *q1 = (queue*) malloc(sizeof(queue));
- q1->next = NULL;
- insert(&q1, 1);
- insert(&q1, 2);
- insert(&q1, 3);
- insert(&q1, 4);
- insert(&q1, 5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement