NLKappa

Homework

Sep 24th, 2017
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         System.out.println("Введите координаты ладьи:");
  9.         Scanner sc = new Scanner (System.in);
  10.         int x1 = sc.nextInt();
  11.         int y1 = sc.nextInt();
  12.         System.out.println("Введите координаты цели:");
  13.         int x2 = sc.nextInt();
  14.         int y2 = sc.nextInt();
  15.         if (x1 > 0 && x1 <= 8 && x2 > 0 && x2 <= 8 && y1 > 0 && y1 <= 8 && y2 > 0 && y2 <= 8) {
  16.             if (x1 == x2 || y1 == y2) {
  17.                 System.out.println("YES. Ладья может достичь цели.");
  18.             } else {
  19.                 System.out.println("NO. Увы, ладья не способна достичь цели.");
  20.             }
  21.         } else {
  22.             System.out.println("Вы ввели недопустимые координаты.");
  23.         }
  24.  
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment