Advertisement
Kancho

From_Chat

Mar 4th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. package Practice;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Substitute {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int k = Integer.parseInt(scanner.nextLine());
  10. int l = Integer.parseInt(scanner.nextLine());
  11. int m = Integer.parseInt(scanner.nextLine());
  12. int n = Integer.parseInt(scanner.nextLine());
  13.  
  14. int counter = 0;
  15.  
  16. boolean firstFirstEven = true;
  17. boolean firstSecondOdd = true;
  18. boolean firstSecondEven = true;
  19. boolean secondSecondOdd = true;
  20.  
  21. boolean areEqual = false;
  22.  
  23. for (int i = k; i <= 8; i++) {
  24. for (int j = 9; j >= l; j--) {
  25. for (int o = m; o <= 8; o++) {
  26. for (int p = 9; p >= n; p--) {
  27. if (counter == 6) {
  28. break;
  29. }
  30. if (i % 2 != 0) {
  31. firstFirstEven = false;
  32. } else {
  33. firstFirstEven = true;
  34. }
  35. if (o % 2 != 0) {
  36. firstSecondEven = false;
  37. } else {
  38. firstSecondEven = true;
  39. }
  40. if (j % 2 == 0) {
  41. firstSecondOdd = false;
  42. } else {
  43. firstSecondOdd = true;
  44. }
  45. if (p % 2 == 0) {
  46. secondSecondOdd = false;
  47. } else {
  48. secondSecondOdd = true;
  49. }
  50. if (i == o && j == p) {
  51. areEqual = true;
  52. } else {
  53. areEqual = false;
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60. if (firstFirstEven && firstSecondOdd && firstSecondEven && secondSecondOdd && !areEqual) {
  61. System.out.printf("%d%d - %d%d%n",i, j, o, p);
  62. counter++;
  63. } else if (firstFirstEven && firstSecondOdd && firstSecondEven && secondSecondOdd && areEqual){
  64. System.out.println("Cannot change the same player.");
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement