Advertisement
Spocoman

Point Of Segment(Ternary Operator)

Sep 9th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int first = Integer.parseInt(scanner.nextLine()),
  7.                 second = Integer.parseInt(scanner.nextLine()),
  8.                 point = Integer.parseInt(scanner.nextLine());
  9.  
  10.         System.out.println(
  11.                 (point <= first && point >= second || point >= first && point <= second ? "in\n" : "out\n")
  12.                         + Math.min(Math.abs(first - point), Math.abs(second - point))
  13.         );
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement