Advertisement
KolosAISD

4Hetmanow

Nov 18th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. class CzterechHetmanow1
  2. {
  3. static int a,b,c,d; // rozkład hetmanów na szachownicy
  4.  
  5. public static void main(String[] args)
  6. {
  7. ustaw();
  8. int i;
  9. for (i = 0; i < 4; i++)
  10. System.out.print(i == a ? "X" : "O");
  11. System.out.println();
  12. for (i = 0; i < 4; i++)
  13. System.out.print(i == b ? "X" : "O");
  14. System.out.println();
  15. for (i = 0; i < 4; i++)
  16. System.out.print(i == c ? "X" : "O");
  17. System.out.println();
  18. for (i = 0; i < 4; i++)
  19. System.out.print(i == d ? "X" : "O");
  20. System.out.println();
  21. }
  22.  
  23. static void ustaw()
  24. {
  25. for (a = 0; a < 4; a++)
  26. for (b = 0; b < 4; b++)
  27. {
  28. if (a == b || a == b-1 || a == b+1) continue;
  29. for (c = 0; c < 4; c++)
  30. {
  31. if (b == c || b == c-1 || b == c+1 ||
  32. a == c || a == c-2 || a == c+2) continue;
  33. for (d = 0; d < 4; d++)
  34. {
  35. if (c == d || c == d-1 || c == d+1 ||
  36. b == d || b == d-2 || b == d+2 ||
  37. a == d || a == d-3 || a == d+3) continue;
  38. return;
  39. }
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement