MiniMi2022

Substitute

Apr 25th, 2023
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Substitute {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int k = Integer.parseInt(scanner.nextLine());
  7.         int l = Integer.parseInt(scanner.nextLine());
  8.         int m = Integer.parseInt(scanner.nextLine());
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.         int count = 0;
  11.         for (int firstD1 = k; firstD1 <= 8; firstD1++) {
  12.             if (firstD1 % 2 != 0) {
  13.                 continue;
  14.             }
  15.             for (int secondD1 = 9; secondD1 >= l; secondD1--) {
  16.                 if (secondD1 % 2 == 0) {
  17.                     continue;
  18.                 }
  19.                 for (int firstD2 = m; firstD2 <= 8; firstD2++) {
  20.                     if (firstD2 % 2 != 0) {
  21.                         continue;
  22.                     }
  23.                     for (int secondD2 = 9; secondD2 >= n; secondD2--) {
  24.                         if (secondD2 % 2 == 0) {
  25.                             continue;
  26.                         }
  27.                         String fistNumber = String.valueOf(firstD1) + String.valueOf(secondD1);
  28.                         String secondNumber = String.valueOf(firstD2) + String.valueOf(secondD2);
  29.                         if (fistNumber.equals(secondNumber)) {
  30.                             System.out.println("Cannot change the same player.");
  31.                         } else {
  32.                             System.out.printf("%s - %s\n", fistNumber, secondNumber);
  33.                             count++;
  34.                             if (count == 6) {
  35.                                 return;
  36.                             }
  37.                         }
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.     }
  43. }
  44.  
Add Comment
Please, Sign In to add comment