apl-mhd

Throw Back Linked List

Jan 23rd, 2019
160
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. struct list{
  6.  
  7.     int data;
  8.  
  9.     struct  list *next;
  10.  
  11.  
  12.  
  13. };
  14.  
  15. int main() {
  16.  
  17.  
  18.     struct  list *node;
  19.     struct  list *temp;
  20.  
  21.     node = new  list();
  22.     node->data = 100;
  23.     node->next = NULL;
  24.  
  25.     temp = new list();
  26.  
  27.     temp->data = 200;
  28.     temp->next = NULL;
  29.  
  30.     node->next = temp;
  31.  
  32.   //  temp = new list();
  33.  
  34.     node->next->next = new list();
  35.  
  36.     node->next->next->data = 300;
  37.  
  38.     cout<<node->data;
  39.     cout<<node->next->data;
  40.     cout<<node->next->next->data;
  41.     return 0;
  42. }
RAW Paste Data