Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- struct spisok
- {
- int num;
- spisok* next;
- };
- void pechat(spisok* first)
- {
- spisok* t = first;
- while (t != NULL)
- {
- printf_s("%d", t->num);
- puts("");
- t = t->next;
- }
- }
- void main()
- {
- spisok* first, * q, * n;
- char stroka[15];
- first = NULL;
- first = new spisok;
- gets_s(stroka, 15);
- first->num = atoi(stroka);
- first->next = NULL;
- n = first;
- while (gets_s(stroka,15),strlen(stroka)!=0)
- {
- q = new spisok;
- n->next = q;
- n = n->next;
- q->num = atoi (stroka);
- q->next = NULL;
- }
- pechat(first);
- while (first != NULL)
- {
- q = first->next;
- delete first;
- first = q;
- }
- pechat(first);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement