Advertisement
Zennoma

pust_budet

Dec 13th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. struct spisok
  5. {
  6.     int num;
  7.     spisok* next;
  8. };
  9.  
  10.  
  11. void pechat(spisok* first)
  12. {
  13.     spisok* t = first;
  14.  
  15.     while (t != NULL)
  16.     {
  17.         printf_s("%d", t->num);
  18.         puts("");
  19.         t = t->next;
  20.     }
  21. }
  22. void main()
  23. {
  24.     spisok* first, * q, * n;
  25.     char stroka[15];
  26.    
  27.             first = NULL;
  28.             first = new spisok;
  29.             gets_s(stroka, 15);
  30.             first->num = atoi(stroka);
  31.             first->next = NULL;
  32.             n = first;
  33.  
  34.             while (gets_s(stroka,15),strlen(stroka)!=0)
  35.             {
  36.                 q = new spisok;
  37.                 n->next = q;
  38.                 n = n->next;
  39.                 q->num = atoi (stroka);
  40.                 q->next = NULL;
  41.             }
  42.             pechat(first);
  43.  
  44.             while (first != NULL)
  45.             {
  46.                
  47.                 q = first->next;
  48.                 delete first;
  49.                 first = q;
  50.                
  51.             }
  52.             pechat(first);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement