Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [anton@notebook tmp]$ cat main.c
- #include <stdlib.h>
- #include <stdio.h>
- typedef struct item {
- int data;
- struct item *next;
- } item;
- int main()
- {
- struct item *first = NULL;
- struct item *tmp;
- int n;
- while (scanf("%d", &n)!= EOF) {
- tmp = (item *)malloc(sizeof(item));
- tmp->data = n;
- tmp->next = first;
- first = tmp;
- }
- tmp = first;
- while (tmp != NULL) {
- printf("%d", tmp->data);
- tmp = tmp->next;
- }
- return 0;
- }
- [anton@notebook tmp]$ gcc main.c -o main
- [anton@notebook tmp]$ ./main
- 1
- 2
- 3
- 4
- 5
- 54321[anton@notebook tmp]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement