Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- struct Node{
- int x;
- struct Node *next;
- };
- int main(){
- srand(time(NULL));
- struct Node *start;
- start = malloc(sizeof(struct Node));
- start->x=(rand() % 10 - 1);
- printf("%d", start->x);
- struct Node *last;
- last = start;
- struct Node *tmp;
- tmp = malloc(sizeof(struct Node));
- for (int i=0; i<9; i++){
- tmp->x=(rand() % 10 - 1);
- last->next = tmp;
- tmp->next = NULL;
- last=tmp;
- printf("%d", tmp->x);
- }
- free(start);
- free(tmp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement