DilyaraL

классы список

Oct 2nd, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. struct node
  4. {
  5. char info;
  6. node* next;
  7. };
  8.  
  9. class List
  10. {
  11. protected: node * head, *marker, *pred;
  12. public:
  13. List();
  14. void Reset();
  15. void Move();
  16. bool EoL();//1 if marker=NULL
  17. void Add(char data);//useless
  18. void Del();
  19. };
  20.  
  21. #include "stdafx.h"
  22. #include "List.h"
  23.  
  24. List::List()
  25. {
  26. head = NULL;
  27. marker = NULL;
  28. pred = marker;
  29. }
  30.  
  31. void List::Reset()
  32. {
  33. marker = head;
  34. pred = marker;
  35. }
  36.  
  37. void List::Move()
  38. {
  39. marker = marker->next;
  40. }
  41.  
  42. bool List::EoL()
  43. {
  44. return (marker==NULL);
  45. }
  46.  
  47. void List::Add(char data)
  48. {
  49. node* p = new node;
  50. p->info = data;
  51. pred->next = p;
  52. p->next = marker;
  53. }
  54.  
  55. void List::Del()
  56. {
  57. node* p = marker;
  58. Move();
  59. pred->next = marker;
  60. delete p;
  61. }
  62. #include "stdafx.h"
  63. #include "List.h"
  64. #include <fstream>
  65.  
  66. using namespace std;
  67.  
  68. class Redoct:public List
  69. {
  70. private:
  71. public:
  72. void creatList(ifstream & f);
  73. void IdWord();
  74. bool Begin(char a);
  75. bool End(char a);//маркер у нас на начале слова
  76. bool InWord(char a);
  77. bool Same(char *a, int n);
  78. node* Copy();// наоборот
  79. bool Palindrom();//
  80. void Perevorot();
  81. void Show();
  82. void Delet();///
  83. };
  84.  
  85. #include "stdafx.h"
  86. #include "RedoctList.h"
  87. #include <fstream>
  88. #include <iostream>
  89.  
  90. using namespace std;
  91.  
  92. void Redoct::creatList(ifstream & f)
  93. {
  94. List();
  95. head = new node;
  96. char data;
  97. node* tail = head;
  98. while (f.get(data))
  99. {
  100. marker = new node;
  101. marker->info = data;
  102. marker->next = NULL;
  103. tail->next = marker;
  104. tail = marker;
  105. }
  106. marker = head;
  107. head=head->next;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment