Advertisement
luluinstalock

Untitled

Jan 25th, 2016
1,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. struct Node{
  6.     int x;
  7.     struct Node *next;
  8. };
  9.  
  10. int main(){
  11.     srand(time(NULL));
  12.     struct Node *start;
  13.     start = malloc(sizeof(struct Node));
  14.    
  15.     start->x=(rand()% 9 + 1);
  16.  
  17.     printf("%d\n", start->x);
  18.    
  19.     struct Node *last;
  20.     last = start;
  21.    
  22.     struct Node *tmp;
  23.     tmp = malloc(sizeof(struct Node));
  24.    
  25.     for (int i=0; i<99; i++){
  26.        
  27.    
  28.         tmp->x=(rand() % 9 + 1);
  29.    
  30.         last->next = tmp;
  31.         tmp->next = NULL;
  32.         last=tmp;
  33.        
  34.         printf("%d\n", tmp->x);
  35.     }
  36.     free(start);
  37.     free(tmp);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement