Advertisement
4rlen

lista

May 26th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct node
  5. {
  6.     int data;
  7.     node* next;
  8. };
  9.  
  10.  
  11. int main()
  12. {
  13.  
  14.    
  15.     node* n;
  16.     node* tmp;
  17.     node* head;
  18.     bool b = false;
  19.  
  20.     for(int i=0; i<4; i++)
  21.     {
  22.         n = new node;
  23.         n->data = i+1;
  24.         if(b == false)
  25.         {
  26.             head = n;
  27.             b = true;
  28.         }
  29.         tmp = n;
  30.         tmp -> next = n;
  31.         tmp = tmp -> next;
  32.     }
  33.     n -> next = NULL;
  34.  
  35.  
  36.    
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement