Advertisement
Dimique

Untitled

Jan 19th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include<iostream>
  2. #include<locale.h>
  3. #include"asd.h"
  4.  
  5. list *adding(list *l, int a) //добавление элемента в список
  6. {
  7.     list *elem = new list;
  8.     elem->name = a;
  9.     elem->next = NULL;
  10.  
  11.     if (l != NULL)
  12.     {
  13.         list *curr = l;
  14.         while (curr->next != NULL)
  15.             curr = curr->next;
  16.         curr->next = elem;
  17.     }
  18.     return(elem);
  19. }
  20.  
  21. list *search(list *l, int value)
  22. {
  23.     list *curr = l;
  24.     list *result = NULL;
  25.     while (curr != NULL)
  26.     {
  27.         if (curr->name == value)
  28.             result = curr;
  29.         curr = curr->next;
  30.     }
  31.     return result;
  32. }
  33.  
  34. void insert(list *l, list *l1)
  35. {
  36.     list *next = l->next;
  37.     l->next = l1;
  38.  
  39.     list *curr = l1;
  40.     while (curr->next != NULL)
  41.         curr = curr->next;
  42.     curr->next = next;
  43. }
  44.  
  45. void deleting(list *M) //удаление первого элемента в
  46. {
  47.     list *temp;
  48.     while (M)
  49.     {
  50.         temp =
  51.             M->next; //записываем адрес элем, который станет корнем
  52.         delete M; // освобождение памяти текущего корня
  53.         M = temp;
  54.     }
  55. }
  56.  
  57. void view(list *l) // просмотр списка+
  58. {
  59.     list *curr = l;
  60.     while (curr != NULL)
  61.     {
  62.         cout << curr->name << " "; // вывод значения элемента p
  63.         curr = curr->next; // переход к следующему узлу
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement