Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_101_January_2016 - created by borkins on 2017-05-03.
- */
- import java.util.Scanner;
- public class _03_PointOnSegment
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int first = Integer.parseInt(console.nextLine());
- int second = Integer.parseInt(console.nextLine());
- int point = Integer.parseInt(console.nextLine());
- int diffFirst = Math.abs(point - first);
- int diffSecond = Math.abs(point - second);
- if (first < second) {
- System.out.println((point >= first && point <= second) ? "in" : "out");
- }
- else {
- System.out.println((point >= second && point <= first) ? "in" : "out");
- }
- System.out.println((diffFirst < diffSecond) ? diffFirst : diffSecond);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment