igorich1376

Logika_игра без излишеств

May 20th, 2025
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 8.29 KB | None | 0 0
  1. ##
  2. // начало + вариант пользователя
  3. var (b,r,g,y,m,c) := ('b','r','g','y','m','c');
  4. var (cnt_plus, cnt_0) := (0, 0);
  5. //
  6. var user_lst := new List<string>;
  7. ///
  8. Println('Всего цветов 6. Введите любые 4 цвета из предложенного списка:');
  9. Println('c(cyan),b(blue),r(red),m(magenta),g(green),y(yellow)');
  10. Println('В игре участвуют только 4 цвета!');
  11. ///
  12. var yes_no := ReadString('Можно начинать игру? Напишите (yes/no) y/n: ');
  13. if (yes_no = 'y') then Println('Ура, начинаем!')
  14.   else
  15.     begin
  16.       Println('Игра завершена!');
  17.       exit
  18.     end;
  19. // вариант компьютера (не видно пользователю)
  20. var auto_lst := new List<string>;
  21. auto_lst.Add(b);
  22. auto_lst.Add(r);
  23. auto_lst.Add(g);
  24. auto_lst.Add(y);
  25. auto_lst.Add(m);
  26. auto_lst.Add(c);
  27. auto_lst := auto_lst.Shuffle;
  28. auto_lst.RemoveAt(0);auto_lst.RemoveAt(0);
  29. Print('Вариант ПК:'); Println(auto_lst);
  30. //
  31. Print('Введите 1-ый цвет (строчными буквами по названию цвета): ');user_lst.Add(ReadString());
  32. Print('Введите 2-ой цвет (строчными буквами по названию цвета): ');user_lst.Add(ReadString());
  33. Print('Введите 3-ий цвет (строчными буквами по названию цвета): ');user_lst.Add(ReadString());
  34. Print('Введите 4-ый цвет (строчными буквами по названию цвета): ');user_lst.Add(ReadString());  
  35. Print('Ваш вариант:'); Print(user_lst);
  36. //
  37. // цвет c
  38. // +
  39. if (user_lst[0] = c) and (auto_lst[0] = c) then cnt_plus += 1
  40. else if (user_lst[1] = c) and (auto_lst[1] = c) then cnt_plus += 1
  41. else if (user_lst[2] = c) and (auto_lst[2] = c) then cnt_plus += 1
  42. else if (user_lst[3] = c) and (auto_lst[3] = c) then cnt_plus += 1
  43. // 0
  44. else if (user_lst[0] = c) and (auto_lst[1] = c) then cnt_0 += 1
  45. else if (user_lst[0] = c) and (auto_lst[2] = c) then cnt_0 += 1
  46. else if (user_lst[0] = c) and (auto_lst[3] = c) then cnt_0 += 1
  47. else if (user_lst[1] = c) and (auto_lst[0] = c) then cnt_0 += 1
  48. else if (user_lst[1] = c) and (auto_lst[2] = c) then cnt_0 += 1
  49. else if (user_lst[1] = c) and (auto_lst[3] = c) then cnt_0 += 1
  50. else if (user_lst[2] = c) and (auto_lst[0] = c) then cnt_0 += 1
  51. else if (user_lst[2] = c) and (auto_lst[1] = c) then cnt_0 += 1
  52. else if (user_lst[2] = c) and (auto_lst[3] = c) then cnt_0 += 1
  53. else if (user_lst[3] = c) and (auto_lst[0] = c) then cnt_0 += 1
  54. else if (user_lst[3] = c) and (auto_lst[1] = c) then cnt_0 += 1
  55. else if (user_lst[3] = c) and (auto_lst[2] = c) then cnt_0 += 1;
  56. // цвет b
  57. // +
  58. if (user_lst[0] = b) and (auto_lst[0] = b) then cnt_plus += 1
  59. else if (user_lst[1] = b) and (auto_lst[1] = b) then cnt_plus += 1
  60. else if (user_lst[2] = b) and (auto_lst[2] = b) then cnt_plus += 1
  61. else if (user_lst[3] = b) and (auto_lst[3] = b) then cnt_plus += 1
  62. // 0
  63. else if (user_lst[0] = b) and (auto_lst[1] = b) then cnt_0 += 1
  64. else if (user_lst[0] = b) and (auto_lst[2] = b) then cnt_0 += 1
  65. else if (user_lst[0] = b) and (auto_lst[3] = b) then cnt_0 += 1
  66. else if (user_lst[1] = b) and (auto_lst[0] = b) then cnt_0 += 1
  67. else if (user_lst[1] = b) and (auto_lst[2] = b) then cnt_0 += 1
  68. else if (user_lst[1] = b) and (auto_lst[3] = b) then cnt_0 += 1
  69. else if (user_lst[2] = b) and (auto_lst[0] = b) then cnt_0 += 1
  70. else if (user_lst[2] = b) and (auto_lst[1] = b) then cnt_0 += 1
  71. else if (user_lst[2] = b) and (auto_lst[3] = b) then cnt_0 += 1
  72. else if (user_lst[3] = b) and (auto_lst[0] = b) then cnt_0 += 1
  73. else if (user_lst[3] = b) and (auto_lst[1] = b) then cnt_0 += 1
  74. else if (user_lst[3] = b) and (auto_lst[2] = b) then cnt_0 += 1;
  75. //
  76. // цвет r
  77. // +
  78. if (user_lst[0] = r) and (auto_lst[0] = r) then cnt_plus += 1
  79. else if (user_lst[1] = r) and (auto_lst[1] = r) then cnt_plus += 1
  80. else if (user_lst[2] = r) and (auto_lst[2] = r) then cnt_plus += 1
  81. else if (user_lst[3] = r) and (auto_lst[3] = r) then cnt_plus += 1
  82. // 0
  83. else if (user_lst[0] = r) and (auto_lst[1] = r) then cnt_0 += 1
  84. else if (user_lst[0] = r) and (auto_lst[2] = r) then cnt_0 += 1
  85. else if (user_lst[0] = r) and (auto_lst[3] = r) then cnt_0 += 1
  86. else if (user_lst[1] = r) and (auto_lst[0] = r) then cnt_0 += 1
  87. else if (user_lst[1] = r) and (auto_lst[2] = r) then cnt_0 += 1
  88. else if (user_lst[1] = r) and (auto_lst[3] = r) then cnt_0 += 1
  89. else if (user_lst[2] = r) and (auto_lst[0] = r) then cnt_0 += 1
  90. else if (user_lst[2] = r) and (auto_lst[1] = r) then cnt_0 += 1
  91. else if (user_lst[2] = r) and (auto_lst[3] = r) then cnt_0 += 1
  92. else if (user_lst[3] = r) and (auto_lst[0] = r) then cnt_0 += 1
  93. else if (user_lst[3] = r) and (auto_lst[1] = r) then cnt_0 += 1
  94. else if (user_lst[3] = r) and (auto_lst[2] = r) then cnt_0 += 1;
  95. //
  96. // цвет g
  97. // +
  98. if (user_lst[0] = g) and (auto_lst[0] = g) then cnt_plus += 1
  99. else if (user_lst[1] = g) and (auto_lst[1] = g) then cnt_plus += 1
  100. else if (user_lst[2] = g) and (auto_lst[2] = g) then cnt_plus += 1
  101. else if (user_lst[3] = g) and (auto_lst[3] = g) then cnt_plus += 1
  102. // 0
  103. else if (user_lst[0] = g) and (auto_lst[1] = g) then cnt_0 += 1
  104. else if (user_lst[0] = g) and (auto_lst[2] = g) then cnt_0 += 1
  105. else if (user_lst[0] = g) and (auto_lst[3] = g) then cnt_0 += 1
  106. else if (user_lst[1] = g) and (auto_lst[0] = g) then cnt_0 += 1
  107. else if (user_lst[1] = g) and (auto_lst[2] = g) then cnt_0 += 1
  108. else if (user_lst[1] = g) and (auto_lst[3] = g) then cnt_0 += 1
  109. else if (user_lst[2] = g) and (auto_lst[0] = g) then cnt_0 += 1
  110. else if (user_lst[2] = g) and (auto_lst[1] = g) then cnt_0 += 1
  111. else if (user_lst[2] = g) and (auto_lst[3] = g) then cnt_0 += 1
  112. else if (user_lst[3] = g) and (auto_lst[0] = g) then cnt_0 += 1
  113. else if (user_lst[3] = g) and (auto_lst[1] = g) then cnt_0 += 1
  114. else if (user_lst[3] = g) and (auto_lst[2] = g) then cnt_0 += 1;
  115. //
  116. // цвет y
  117. // +
  118. if (user_lst[0] = y) and (auto_lst[0] = y) then cnt_plus += 1
  119. else if (user_lst[1] = y) and (auto_lst[1] = y) then cnt_plus += 1
  120. else if (user_lst[2] = y) and (auto_lst[2] = y) then cnt_plus += 1
  121. else if (user_lst[3] = y) and (auto_lst[3] = y) then cnt_plus += 1
  122. // 0
  123. else if (user_lst[0] = y) and (auto_lst[1] = y) then cnt_0 += 1
  124. else if (user_lst[0] = y) and (auto_lst[2] = y) then cnt_0 += 1
  125. else if (user_lst[0] = y) and (auto_lst[3] = y) then cnt_0 += 1
  126. else if (user_lst[1] = y) and (auto_lst[0] = y) then cnt_0 += 1
  127. else if (user_lst[1] = y) and (auto_lst[2] = y) then cnt_0 += 1
  128. else if (user_lst[1] = y) and (auto_lst[3] = y) then cnt_0 += 1
  129. else if (user_lst[2] = y) and (auto_lst[0] = y) then cnt_0 += 1
  130. else if (user_lst[2] = y) and (auto_lst[1] = y) then cnt_0 += 1
  131. else if (user_lst[2] = y) and (auto_lst[3] = y) then cnt_0 += 1
  132. else if (user_lst[3] = y) and (auto_lst[0] = y) then cnt_0 += 1
  133. else if (user_lst[3] = y) and (auto_lst[1] = y) then cnt_0 += 1
  134. else if (user_lst[3] = y) and (auto_lst[2] = y) then cnt_0 += 1;
  135. //
  136. // цвет m
  137. // +
  138. if (user_lst[0] = m) and (auto_lst[0] = m) then cnt_plus += 1
  139. else if (user_lst[1] = m) and (auto_lst[1] = m) then cnt_plus += 1
  140. else if (user_lst[2] = m) and (auto_lst[2] = m) then cnt_plus += 1
  141. else if (user_lst[3] = m) and (auto_lst[3] = m) then cnt_plus += 1
  142. // 0
  143. else if (user_lst[0] = m) and (auto_lst[1] = m) then cnt_0 += 1
  144. else if (user_lst[0] = m) and (auto_lst[2] = m) then cnt_0 += 1
  145. else if (user_lst[0] = m) and (auto_lst[3] = m) then cnt_0 += 1
  146. else if (user_lst[1] = m) and (auto_lst[0] = m) then cnt_0 += 1
  147. else if (user_lst[1] = m) and (auto_lst[2] = m) then cnt_0 += 1
  148. else if (user_lst[1] = m) and (auto_lst[3] = m) then cnt_0 += 1
  149. else if (user_lst[2] = m) and (auto_lst[0] = m) then cnt_0 += 1
  150. else if (user_lst[2] = m) and (auto_lst[1] = m) then cnt_0 += 1
  151. else if (user_lst[2] = m) and (auto_lst[3] = m) then cnt_0 += 1
  152. else if (user_lst[3] = m) and (auto_lst[0] = m) then cnt_0 += 1
  153. else if (user_lst[3] = m) and (auto_lst[1] = m) then cnt_0 += 1
  154. else if (user_lst[3] = m) and (auto_lst[2] = m) then cnt_0 += 1;
  155. //
  156. if cnt_plus = 1 then Print('+')
  157.   else if cnt_plus = 2 then Print('+ +')
  158.     else if cnt_plus = 3 then Print('+ + +')
  159.       else if cnt_plus = 1 then Print('+ + + +');
  160. if cnt_0 = 1 then Print('0')
  161.   else if cnt_0 = 2 then Print('0 0')
  162.     else if cnt_0 = 3 then Print('0 0 0')
  163.       else if cnt_0 = 4 then Print('0 0 0 0')
  164.  
Advertisement
Add Comment
Please, Sign In to add comment