fork(1) download
  1. #include <initializer_list>
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <iterator>
  5. #include <vector>
  6. #include <utility>
  7. #include<cstring>
  8. #include<string>
  9.  
  10. using namespace std;
  11.  
  12. class TListNode{
  13.  
  14. public:
  15. string Dat;
  16. TListNode * Fnext;
  17. TListNode * Fprev;
  18.  
  19. TListNode():Fnext(nullptr),Fprev(nullptr){}
  20. TListNode * & Next(){return Fnext;}
  21. TListNode * & Prev(){return Fprev;}
  22. string & Get() {return Dat;}
  23.  
  24.  
  25.  
  26. };
  27.  
  28.  
  29. class TList{
  30. public:
  31.  
  32. TListNode * Fbegin;
  33. TListNode * Fend;
  34. int NomerFaila;
  35. int FnodeCount;
  36. std::initializer_list<string> list;
  37.  
  38. TList():Fbegin(0),Fend(0), FnodeCount(0) {};
  39. TList(const std::initializer_list<string> & list);
  40.  
  41. TListNode * push_back(const string & dat);
  42.  
  43. TListNode * Begin(){return Fbegin;}
  44. TListNode * End(){return Fend;}
  45. int NodesCount(){return FnodeCount;}
  46.  
  47. };
  48.  
  49.  
  50. TList::TList( const std::initializer_list<string>& list):TList()
  51. { std::for_each(list.begin(), list.end(), [this]( const string & d) {this->push_back(d); });
  52.  
  53. }
  54.  
  55. TListNode* TList:: push_back(const string & dat)
  56. { TListNode* node = new TListNode;
  57. node->Get() = dat; node->Next() = 0;
  58. if ( Fend ) Fend->Next() = node;
  59. node->Prev()= Fend;
  60. Fend = node; FnodeCount++;
  61. if (!Fbegin) Fbegin = node;
  62. return node;
  63. }
  64. struct My_String {
  65. string S;
  66. int Nomer;
  67. };
  68.  
  69.  
  70.  
  71. using namespace std;
  72.  
  73. vector <TList> vect;
  74. vector <My_String> vect2;
  75.  
  76. void Print( TList & list)
  77. { TListNode * node = list.Begin();
  78.  
  79. while (node != nullptr)
  80. {
  81. cout << node->Get();
  82. cout << list.NomerFaila<<endl;
  83. node = node->Next();
  84. }
  85. }
  86.  
  87. void Print_V(vector <TList> &V) {
  88. //for (vector<TList>::iterator it = V.begin(); it != V.end(); it++) {
  89. for (int i=0;i<V.size();i++) {
  90. Print(V[i]);
  91. }
  92. //}
  93. }
  94. void Print_V22(vector <My_String> &V22) {
  95. for (vector<My_String>::iterator it = V22.begin(); it != V22.end(); it++) {
  96. //for (int i=0;i<V22.size();i++) {
  97. cout<<it->S<<it->Nomer;
  98.  
  99. }
  100. //}
  101. }
  102. void Convert ( TList & list, My_String &Str)
  103. { TListNode * node = list.Begin();
  104.  
  105. while (node != nullptr)
  106. {
  107. Str.S = node->Get();
  108. Str.Nomer = list.NomerFaila;
  109.  
  110. vect2.push_back(Str);
  111. node = node->Next();
  112. }
  113. }
  114.  
  115.  
  116.  
  117. void Sortirovka ( vector <My_String> &V222)
  118. {
  119. for (vector<My_String>::iterator it = V222.begin(); it != V222.end(); it++)
  120. {
  121. if (strcmp ( (it->S), "1")==0) {
  122. for (vector<My_String>::iterator it2 = it+1; it2 != V222.end() ; it2++)
  123. {
  124.  
  125. V222[1]=V222[2];
  126. V222.pop_back();
  127. }
  128.  
  129. }
  130. }
  131. }
  132.  
  133.  
  134. int main()
  135. {
  136. setlocale(LC_ALL, "Russian");
  137.  
  138. TList L {"1","2","3"};
  139. L.NomerFaila=1;
  140. //Print (L);
  141. TList LL {"4","5","2"};
  142. LL.NomerFaila=2;
  143. vector <TList> vect;
  144. vect.push_back(L);
  145. vect.push_back(LL);
  146. //Print_V (vect);
  147.  
  148. My_String Struct;
  149. Convert ( L, Struct);
  150. Print_V22(vect2);
  151. /*
  152. TListNode * node = LL.Begin();
  153. while (node != nullptr)
  154. {
  155. Struct.S=node->Get();
  156. vect2.push_back(Struct.S);
  157. }
  158. */
  159.  
  160.  
  161.  
  162.  
  163. system("pause");
  164.  
  165. return 0;
  166. }
  167.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void Sortirovka(std::vector<My_String>&)’:
prog.cpp:121:29: error: cannot convert ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘const char*’ for argument ‘1’ to ‘int strcmp(const char*, const char*)’
   if  (strcmp ( (it->S), "1")==0)  {
                             ^
stdout
Standard output is empty