igorich1376

Logika_сама игра (чет сломалась)...

May 20th, 2025 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 4.48 KB | None | 0 0
  1. ## uses crt;
  2. // начало + вариант пользователя
  3. var (b,r,g,y,m,c) := (' BB',' RR',' GG',' YY',' MM',' CC');
  4. var user_lst := new List<string>;
  5. ///
  6. Println('Введите любые 4 цвета из предложенного списка:');
  7. Println('C(cyan),B(blue),R(red),M(magenta),G(green),Y(yellow)');
  8. Println('В игре участвуют только 4 цвета!');
  9. ///
  10. var yes_no := ReadString('Можно начинать игру? Напишите (yes/no) y/n: ');
  11. ///
  12. if (yes_no = 'y') or (yes_no = 'Y') then
  13. begin
  14.   for var i := 1 to 4 do
  15.   begin
  16.     Print($'Введите {i}-ый цвет (строчными буквами по названию цвета): ');
  17.     user_lst.Add(ReadString());
  18.   end;
  19. end
  20. else
  21. begin
  22.   Println('Игра окончена!');
  23.   exit
  24. end;
  25.  
  26. // вариант компьютера (не видно пользователю)
  27.  
  28. var auto_lst := new List<string>;
  29. auto_lst.Add(b);
  30. auto_lst.Add(r);
  31. auto_lst.Add(g);
  32. auto_lst.Add(y);
  33. auto_lst.Add(m);
  34. auto_lst.Add(c);
  35. auto_lst := auto_lst.Shuffle;
  36. auto_lst.RemoveAt(0);auto_lst.RemoveAt(0);
  37. //////////////////////////////////////////////////////////
  38. Print('Ваш вариант: '); Println(user_lst);
  39.  
  40. if (user_lst[0] = b)
  41. then
  42.   begin
  43.     TextBackground(crt.LightBlue);
  44.     TextColor(crt.Black);
  45.     Print(' BB');
  46.   end
  47. else if (user_lst[0] = r)
  48. then
  49.   begin
  50.     TextBackground(crt.LightRed);
  51.     TextColor(crt.Black);
  52.     Print(' RR');
  53.   end
  54.  else if (user_lst[0] = g)
  55. then
  56.   begin
  57.     TextBackground(crt.LightGreen);
  58.     TextColor(crt.Black);
  59.     Print(' GG');
  60.   end
  61. else if (user_lst[0] = y)
  62. then
  63.   begin
  64.     TextBackground(crt.Yellow);
  65.     TextColor(crt.Black);
  66.     Print(' YY');
  67.   end
  68. else if (user_lst[0] = m)
  69. then
  70.   begin
  71.     TextBackground(crt.LightMagenta);
  72.     TextColor(crt.Black);
  73.     Print(' MM');
  74.   end
  75. else if (user_lst[0] = c)
  76. then
  77.   begin
  78.     TextBackground(crt.LightCyan);
  79.     TextColor(crt.Black);
  80.     Print(' CC');
  81.   end;
  82. // индекс 1
  83. if (user_lst[1] = b)
  84. then
  85.   begin
  86.     TextBackground(crt.LightBlue);
  87.     TextColor(crt.Black);
  88.     Print(' BB');
  89.   end
  90. else if (user_lst[1] = r)
  91. then
  92.   begin
  93.     TextBackground(crt.LightRed);
  94.     TextColor(crt.Black);
  95.     Print(' RR');
  96.   end
  97.  else if (user_lst[1] = g)
  98. then
  99.   begin
  100.     TextBackground(crt.LightGreen);
  101.     TextColor(crt.Black);
  102.     Print(' GG');
  103.   end
  104. else if (user_lst[1] = y)
  105. then
  106.   begin
  107.     TextBackground(crt.Yellow);
  108.     TextColor(crt.Black);
  109.     Print(' YY');
  110.   end
  111. else if (user_lst[1] = m)
  112. then
  113.   begin
  114.     TextBackground(crt.LightMagenta);
  115.     TextColor(crt.Black);
  116.     Print(' MM');
  117.   end
  118. else if (user_lst[1] = c)
  119. then
  120.   begin
  121.     TextBackground(crt.LightCyan);
  122.     TextColor(crt.Black);
  123.     Print(' CC');
  124.   end;
  125. // индекс 2
  126. if (user_lst[2] = b)
  127. then
  128.   begin
  129.     TextBackground(crt.LightBlue);
  130.     TextColor(crt.Black);
  131.     Print(' BB');
  132.   end
  133. else if (user_lst[2] = r)
  134. then
  135.   begin
  136.     TextBackground(crt.LightRed);
  137.     TextColor(crt.Black);
  138.     Print(' RR');
  139.   end
  140.  else if (user_lst[2] = g)
  141. then
  142.   begin
  143.     TextBackground(crt.LightGreen);
  144.     TextColor(crt.Black);
  145.     Print(' GG');
  146.   end
  147. else if (user_lst[2] = y)
  148. then
  149.   begin
  150.     TextBackground(crt.Yellow);
  151.     TextColor(crt.Black);
  152.     Print(' YY');
  153.   end
  154. else if (user_lst[2] = m)
  155. then
  156.   begin
  157.     TextBackground(crt.LightMagenta);
  158.     TextColor(crt.Black);
  159.     Print(' MM');
  160.   end
  161. else if (user_lst[2] = c)
  162. then
  163.   begin
  164.     TextBackground(crt.LightCyan);
  165.     TextColor(crt.Black);
  166.     Print(' CC');
  167.   end;
  168. // индекс 3
  169. if (user_lst[3] = b)
  170. then
  171.   begin
  172.     TextBackground(crt.LightBlue);
  173.     TextColor(crt.Black);
  174.     Print(' BB');
  175.   end
  176. else if (user_lst[3] = r)
  177. then
  178.   begin
  179.     TextBackground(crt.LightRed);
  180.     TextColor(crt.Black);
  181.     Print(' RR');
  182.   end
  183.  else if (user_lst[3] = g)
  184. then
  185.   begin
  186.     TextBackground(crt.LightGreen);
  187.     TextColor(crt.Black);
  188.     Print(' GG');
  189.   end
  190. else if (user_lst[3] = y)
  191. then
  192.   begin
  193.     TextBackground(crt.Yellow);
  194.     TextColor(crt.Black);
  195.     Print(' YY');
  196.   end
  197. else if (user_lst[3] = m)
  198. then
  199.   begin
  200.     TextBackground(crt.LightMagenta);
  201.     TextColor(crt.Black);
  202.     Print(' MM');
  203.   end
  204. else if (user_lst[3] = c)
  205. then
  206.   begin
  207.     TextBackground(crt.LightCyan);
  208.     TextColor(crt.Black);
  209.     Print(' CC');
  210.   end;
  211.  
  212. readln()
  213.  
  214. // что-то затык произошёл, программа не идёт дальше...
Advertisement
Add Comment
Please, Sign In to add comment