Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct Node
- {
- int data;
- struct Node *next;
- struct Node *prev;
- }Node_t;
- Node_t *next = NULL;
- Node_t *prev = NULL;
- Node_t *root = NULL;
- Node_t *tail = NULL;
- void push_front(int data) // v nachalo
- {
- Node_t * temp = NULL;
- temp = (Node_t *)malloc(sizeof(Node_t));
- temp->data = data;
- temp->next = NULL;
- }
- void push(Node_t * head, int data) // в конец
- {
- Node_t * current = head;
- while (current->next != NULL)
- {
- current = current->next;
- }
- current->next = (Node_t *)malloc(sizeof(Node_t));
- current->next->data = data;
- current->next->next = NULL;
- }
- void printList()
- {
- Node_t *temp = root;
- while (temp != NULL)
- {
- printf("%d", temp->data);
- temp = temp->next;
- }
- printf('\n');
- }
- int main()
- {
- push_front(110);
- push_front(20);
- push_front(330);
- push_front(41);
- push_front(40);
- push_front(56);
- printList();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement