Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Practice;
- import java.util.Scanner;
- public class Substitute {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int k = Integer.parseInt(scanner.nextLine());
- int l = Integer.parseInt(scanner.nextLine());
- int m = Integer.parseInt(scanner.nextLine());
- int n = Integer.parseInt(scanner.nextLine());
- int counter = 0;
- boolean firstFirstEven = true;
- boolean firstSecondOdd = true;
- boolean firstSecondEven = true;
- boolean secondSecondOdd = true;
- boolean areEqual = false;
- for (int i = k; i <= 8; i++) {
- for (int j = 9; j >= l; j--) {
- for (int o = m; o <= 8; o++) {
- for (int p = 9; p >= n; p--) {
- if (counter == 6) {
- break;
- }
- if (i % 2 != 0) {
- firstFirstEven = false;
- } else {
- firstFirstEven = true;
- }
- if (o % 2 != 0) {
- firstSecondEven = false;
- } else {
- firstSecondEven = true;
- }
- if (j % 2 == 0) {
- firstSecondOdd = false;
- } else {
- firstSecondOdd = true;
- }
- if (p % 2 == 0) {
- secondSecondOdd = false;
- } else {
- secondSecondOdd = true;
- }
- if (i == o && j == p) {
- areEqual = true;
- } else {
- areEqual = false;
- }
- if (firstFirstEven && firstSecondOdd && firstSecondEven && secondSecondOdd && !areEqual) {
- System.out.printf("%d%d - %d%d%n",i, j, o, p);
- counter++;
- } else if (firstFirstEven && firstSecondOdd && firstSecondEven && secondSecondOdd && areEqual){
- System.out.println("Cannot change the same player.");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement