dsavov_02

точка върху отсечка

Nov 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int first = int.Parse(Console.ReadLine());
  8.         int second = int.Parse(Console.ReadLine());
  9.         int point = int.Parse(Console.ReadLine());
  10.         int left = Math.Min(first, second);
  11.         int right = Math.Max(first, second);
  12.        
  13.         if (point >= left && point <= right)
  14.         {
  15.             Console.WriteLine("in");
  16.         }
  17.         else
  18.         {
  19.             Console.WriteLine("out");          
  20.         }
  21.         int d = Math.Min(Math.Abs(left - point), Math.Abs(right - point));
  22.         Console.WriteLine(d);
  23.     }
  24. }
Add Comment
Please, Sign In to add comment