Kwwiker

createList

Mar 12th, 2021
586
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void createList(Node*& head, int n) {
  2.     Node* newNode, * temp = NULL;
  3.     for (int i = 0; i < n; i++) {
  4.         newNode = new Node;
  5.         cout << "Введите значение узла: ";
  6.         cin >> newNode->info;
  7.         newNode->next = NULL;
  8.         if (head == NULL) {
  9.             head = newNode;
  10.             temp = head;
  11.         }
  12.         else {
  13.             temp->next = newNode;
  14.             temp = temp->next;
  15.         }
  16.     }
  17. }
  18.  
RAW Paste Data