igorich1376

Games Logika_логика игры

May 20th, 2025
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.16 KB | None | 0 0
  1. ## //логика игры
  2. var auto_lst := new List<string>;
  3. auto_lst.Add('C');
  4. auto_lst.Add('B');
  5. auto_lst.Add('R');
  6. auto_lst.Add('M');
  7. auto_lst.Add('G');
  8. auto_lst.Add('W');
  9. auto_lst := auto_lst.Shuffle;
  10. auto_lst.RemoveAt(0);auto_lst.RemoveAt(0); // вариант компьютера готов!
  11. Println('Вариант компьютера: ',auto_lst);
  12. ///
  13. var user_lst := new List<string>;
  14. for var i := 1 to 4 do
  15.   begin
  16.     Print($'Введите {i}-ый цвет: ');
  17.     user_lst.Add(ReadString());
  18.   end;
  19. Print('Ваш вариант:        ', user_lst);
  20. var (cnt_plus, cnt_0) := (0, 0);
  21. // цвет С
  22. // +
  23. if (user_lst[0] = 'C') and (auto_lst[0] = 'C') then cnt_plus += 1
  24. else if (user_lst[1] = 'C') and (auto_lst[1] = 'C') then cnt_plus += 1
  25. else if (user_lst[2] = 'C') and (auto_lst[2] = 'C') then cnt_plus += 1
  26. else if (user_lst[3] = 'C') and (auto_lst[3] = 'C') then cnt_plus += 1
  27. // 0
  28. else if (user_lst[0] = 'C') and (auto_lst[1] = 'C') then cnt_0 += 1
  29. else if (user_lst[0] = 'C') and (auto_lst[2] = 'C') then cnt_0 += 1
  30. else if (user_lst[0] = 'C') and (auto_lst[3] = 'C') then cnt_0 += 1
  31. else if (user_lst[1] = 'C') and (auto_lst[0] = 'C') then cnt_0 += 1
  32. else if (user_lst[1] = 'C') and (auto_lst[2] = 'C') then cnt_0 += 1
  33. else if (user_lst[1] = 'C') and (auto_lst[3] = 'C') then cnt_0 += 1
  34. else if (user_lst[2] = 'C') and (auto_lst[0] = 'C') then cnt_0 += 1
  35. else if (user_lst[2] = 'C') and (auto_lst[1] = 'C') then cnt_0 += 1
  36. else if (user_lst[2] = 'C') and (auto_lst[3] = 'C') then cnt_0 += 1
  37. else if (user_lst[3] = 'C') and (auto_lst[0] = 'C') then cnt_0 += 1
  38. else if (user_lst[3] = 'C') and (auto_lst[1] = 'C') then cnt_0 += 1
  39. else if (user_lst[3] = 'C') and (auto_lst[2] = 'C') then cnt_0 += 1;
  40. // цвет B
  41. // +
  42. if (user_lst[0] = 'B') and (auto_lst[0] = 'B') then cnt_plus += 1
  43. else if (user_lst[1] = 'B') and (auto_lst[1] = 'B') then cnt_plus += 1
  44. else if (user_lst[2] = 'B') and (auto_lst[2] = 'B') then cnt_plus += 1
  45. else if (user_lst[3] = 'B') and (auto_lst[3] = 'B') then cnt_plus += 1
  46. // 0
  47. else if (user_lst[0] = 'B') and (auto_lst[1] = 'B') then cnt_0 += 1
  48. else if (user_lst[0] = 'B') and (auto_lst[2] = 'B') then cnt_0 += 1
  49. else if (user_lst[0] = 'B') and (auto_lst[3] = 'B') then cnt_0 += 1
  50. else if (user_lst[1] = 'B') and (auto_lst[0] = 'B') then cnt_0 += 1
  51. else if (user_lst[1] = 'B') and (auto_lst[2] = 'B') then cnt_0 += 1
  52. else if (user_lst[1] = 'B') and (auto_lst[3] = 'B') then cnt_0 += 1
  53. else if (user_lst[2] = 'B') and (auto_lst[0] = 'B') then cnt_0 += 1
  54. else if (user_lst[2] = 'B') and (auto_lst[1] = 'B') then cnt_0 += 1
  55. else if (user_lst[2] = 'B') and (auto_lst[3] = 'B') then cnt_0 += 1
  56. else if (user_lst[3] = 'B') and (auto_lst[0] = 'B') then cnt_0 += 1
  57. else if (user_lst[3] = 'B') and (auto_lst[1] = 'B') then cnt_0 += 1
  58. else if (user_lst[3] = 'B') and (auto_lst[2] = 'B') then cnt_0 += 1;
  59. //
  60. if cnt_plus = 1 then Print('+')
  61.   else if cnt_plus = 2 then Print('+ +')
  62.     else if cnt_plus = 3 then Print('+ + +')
  63.       else if cnt_plus = 1 then Print('+ + + +');
  64. if cnt_0 = 1 then Print('0')
  65.   else if cnt_0 = 2 then Print('0 0')
  66.     else if cnt_0 = 3 then Print('0 0 0')
  67.       else if cnt_0 = 4 then Print('0 0 0 0')
  68.  
Advertisement
Add Comment
Please, Sign In to add comment