Advertisement
Guest User

Linked List

a guest
Sep 30th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. int age[5] = { 19, 21, 17, 22, 33 };//Given array
  2.  
  3.     NODE *list;
  4.     NODE *P;
  5.  
  6.     list = new(NODE);
  7.     list->info = age[0];
  8.     P = list;
  9.    
  10.  
  11.     for (int i = 1; i < 5; i++)
  12.     {
  13.         P->next = new NODE;
  14.         P->info = age[i];
  15.     }
  16.     P->next = NULL;
  17.  
  18.  
  19.     while (P != NULL)
  20.     {
  21.         cout << P->info << "->";
  22.         P = P->next;
  23.     }
  24.     cout << "NULL\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement