Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Point_on_Segment
- {
- class Program
- {
- static void Main(string[] args)
- {
- int first = int.Parse(Console.ReadLine());
- int second = int.Parse(Console.ReadLine());
- int point = int.Parse(Console.ReadLine());
- int minDist = 0;
- int min = 0;
- int max = 0;
- int difFirst = Math.Abs(first - point);
- int difSecond = Math.Abs(second - point);
- if (first < second)
- {
- min = first;
- max = second;
- }
- else
- {
- min = second;
- max = first;
- }
- if (difFirst < difSecond)
- {
- minDist = difFirst;
- }
- else
- {
- minDist = difSecond;
- }
- if (point >= min && point <= max)
- {
- Console.WriteLine("in");
- Console.WriteLine(minDist);
- }
- else
- {
- Console.WriteLine("out");
- Console.WriteLine(minDist);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement