Advertisement
Zennoma

shurikneloh

Feb 29th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <locale.h>
  5. #include <iostream>
  6. #include<time.h>
  7.  
  8. using namespace std;
  9. struct elem {
  10. char word[250];
  11. elem* next;
  12. };
  13.  
  14. void pechat(elem* first)
  15. {
  16. elem* q = first;
  17. while (q != NULL)
  18. {
  19. puts(q->word);
  20. q = q->next;
  21. }
  22. delete q;
  23. }
  24.  
  25. int main() {
  26. setlocale(LC_ALL, "rus");
  27. elem* first, * nextly,*p;
  28.  
  29. char* meow = new char[200];
  30. char* omg = new char[200];
  31. first = NULL; //cписок пуст
  32. //заполняю первый вагончик
  33. puts("Введите строки");
  34. gets_s(meow, 200);//пока всё спокойно
  35. //не теряю указатель на первый элемент
  36. first = new elem;
  37. strcpy_s(first->word, strlen(meow)+1, meow);
  38. //двигаем вагончк два
  39. p = first;
  40. first->next = NULL;
  41.  
  42. while (gets_s(meow,200),strlen(meow)!= 0)
  43. {
  44. nextly = new elem;
  45. strcpy_s(nextly->word, strlen(meow)+1, meow);
  46. p->next = nextly;
  47. p = p->next;//двигаем вагончик раз
  48. p->next = NULL;//двигаем вагончк два
  49.  
  50. }
  51. pechat(first);
  52. //печать структуры
  53.  
  54. //
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement