Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. #include <QCoreApplication>
  2. #include <QVector>
  3. #include <QString>
  4. #include <QStringList>
  5. #include <QTextStream>
  6. #include <QtDebug>
  7. QTextStream cout(stdout);
  8. QTextStream cin(stdin);
  9.  
  10.  
  11.  
  12. class Tru
  13. {
  14. QVector<QVector<QString>> approvals;
  15. QVector<QVector<QString>> answers;
  16. QVector<QString> pre;
  17. public:
  18. Tru(){}
  19. void GetData()
  20. {
  21. QString a;
  22. a = cin.readLine();
  23.  
  24. QStringList a1 = a.split("=");
  25. QString before;
  26. QString after;
  27. for(int i = 0; i < a1.size() - 1; i++)
  28. {
  29. before = a1.at(i);
  30. after = a1.at(i+1);
  31. }
  32. QStringList before1 = before.split(" ");
  33. QStringList after1 = after.split(" ");
  34. QVector<QString> before2;
  35. QVector<QString> after2;
  36. for(int i = 0; i < before1.size(); i++)
  37. {
  38. before2.push_back(before1.at(i));
  39. }
  40. for(int i = 0; i < after1.size(); i++)
  41. {
  42. after2.push_back(after1.at(i));
  43. }
  44. approvals.push_back(before2);
  45. answers.push_back(after2);
  46. }
  47.  
  48. void GetPre()
  49. {
  50.  
  51. QString a;
  52. a= cin.readLine();
  53. QStringList b = a.split(" ");
  54. for(int i = 0; i < b.size(); i++)
  55. {
  56. pre.push_back(b.at(i));
  57. }
  58. }
  59.  
  60. void FindSolution()
  61. {
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. for(int i = 0; i < pre.size(); i++)
  70. {
  71. for(int j = 0; j < approvals.size(); j++)
  72. {
  73. for(int k = 0; k < approvals.at(j).size(); k++)
  74. {
  75. if(pre.at(i) == approvals.at(j).at(k))
  76. {
  77. qDebug() << answers.at(j).at(k);
  78. }
  79. }
  80. // if(counter == approvals.at(j).size())
  81. // {
  82. // for(int m = 0; m < answers.at(j).size(); m++)
  83. // {
  84. // qDebug() << answers.at(j).at(m);
  85. // }
  86. // }
  87. }
  88. }
  89. }
  90.  
  91. ~Tru(){}
  92.  
  93. };
  94.  
  95.  
  96.  
  97.  
  98.  
  99. class ALLtru
  100. {
  101.  
  102. };
  103.  
  104. int main(int argc, char *argv[])
  105. {
  106. QCoreApplication a(argc, argv);
  107. QString foo;
  108. Tru b;
  109. while(foo != "ex")
  110. {
  111. foo = cin.readLine();
  112.  
  113.  
  114. if(foo == "da")
  115. {
  116.  
  117. b.GetData();
  118. }
  119. else
  120. {
  121. if(foo == "pr")
  122. {
  123. b.GetPre();
  124. }
  125. else
  126. {
  127. if(foo == "so")
  128. {
  129. b.FindSolution();
  130. }
  131. }
  132. }
  133. }
  134.  
  135. return a.exec();
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement