Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- System.out.println("Введите координаты ладьи:");
- Scanner sc = new Scanner (System.in);
- int x1 = sc.nextInt();
- int y1 = sc.nextInt();
- System.out.println("Введите координаты цели:");
- int x2 = sc.nextInt();
- int y2 = sc.nextInt();
- if (x1 > 0 && x1 <= 8 && x2 > 0 && x2 <= 8 && y1 > 0 && y1 <= 8 && y2 > 0 && y2 <= 8) {
- if (x1 == x2 || y1 == y2) {
- System.out.println("YES. Ладья может достичь цели.");
- } else {
- System.out.println("NO. Увы, ладья не способна достичь цели.");
- }
- } else {
- System.out.println("Вы ввели недопустимые координаты.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment