Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdlib.h"
- #include <iostream>
- using namespace std;
- struct node
- {
- int info;
- node* next;
- };
- typedef node* NodeP; // указатель на тип node
- NodeP head = NULL; // указатель на начало списка
- NodeP p; // указатель на текущий элемент
- NodeP tail;
- int number;
- node* create(NodeP)
- {
- int let = 1;
- int i, num;
- tail = head; // указатель на конец списка
- while (let)
- {
- printf("vv elem\n");
- scanf_s("%d", &number);
- p = (node*)malloc(sizeof(node));
- if (head == NULL) // если список пуст
- {
- head = p;// выделение памяти для нового элемента
- head->info = number; // запись значения в список
- head->next = NULL;
- tail = head;
- }
- else
- {
- p->info = number;
- tail->next = p;
- p->next = NULL;
- tail = p;
- printf("continue (1/0)? ");
- scanf_s("%d", &let);
- }
- }
- return tail;
- }
- void SearchZn(NodeP)
- {
- tail = head;
- while (tail != NULL)
- {
- printf("%d\n", tail->info);
- tail = tail->next;
- }
- if (tail == NULL)
- cout << "net znachenia" << endl;
- return;
- }
- int main()
- {
- int menu;
- create(p);
- SearchZn(p);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement