Advertisement
q1sm4t

Untitled

Apr 11th, 2021
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. using namespace std;
  5.  
  6. struct n {
  7.     int x;
  8.     n * next;
  9. };
  10.  
  11. typedef n node;
  12.  
  13. int main ()
  14. {
  15.     int var;
  16.     node * root;
  17.     root = (node *)malloc(sizeof(node));
  18.     node * iter;
  19.     iter = root;
  20.     for(int i=0;i<5;i++){
  21.         iter->x = i;
  22.         iter = iter->next;
  23.     }
  24.    
  25.     for(int j=0;j<5;j++){
  26.         var = iter->x;
  27.         cout<<var;
  28.         iter = iter->next;
  29.     }
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement