Advertisement
rihardmarius

estructuras enlazadas

Nov 23rd, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct node {
  6.   char entry = 'a'; // valores por defecto
  7.   node *next = nullptr;
  8. };
  9.  
  10. int main()
  11. {
  12.     node *p0 = new node;
  13.     node *p1 = new node;
  14.     node *p2 = new node;
  15.  
  16.     p0->next = p1;
  17.     p1->next = p2;
  18.  
  19.     for (node *p = p0; p != 0; p = p->next)
  20.         cout << p->entry << ' ';
  21.     cout << endl;
  22.  
  23.     p1->entry = 'b';
  24.     p2->entry = 'c';
  25.  
  26.     for (node *p = p0; p != 0; p = p->next)
  27.         cout << p->entry << ' ';
  28.     cout << endl;
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement