Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2016
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int x1 = int.Parse(Console.ReadLine());
  8.         int x2 = int.Parse(Console.ReadLine());
  9.         int x = int.Parse(Console.ReadLine());
  10.  
  11.         if (x>= Math.Min(x1,x2)&&x<=Math.Max(x1,x2))
  12.         {
  13.             Console.WriteLine("in");
  14.             if (Math.Abs(x1-x)<Math.Abs(x2-x))
  15.             {
  16.                 Console.WriteLine(Math.Abs(x1-x));
  17.             }
  18.             else
  19.             {
  20.                 Console.WriteLine(Math.Abs(x2-x));
  21.             }
  22.         }
  23.         else
  24.         {
  25.             Console.WriteLine("out");
  26.             if (Math.Abs(x1 - x) < Math.Abs(x2 - x))
  27.             {
  28.                 Console.WriteLine(Math.Abs(x1 - x));
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine(Math.Abs(x2 - x));
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement