Advertisement
saimun1

[EXAM PREP] Point on Segment 80/100

Jul 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main() //https://csharp-book.softuni.bg/chapter-08-exam-preparation.html
  5.     {
  6.         var first = double.Parse(Console.ReadLine());
  7.         var second = double.Parse(Console.ReadLine());
  8.         var point = double.Parse(Console.ReadLine());
  9.  
  10.         var left = Math.Min(first, second);
  11.         var right = Math.Max(first, second);
  12.         var leftDistance = Math.Abs(point - left);
  13.         var rightDistance = Math.Abs(point - right);
  14.         if(point<right && point > left)
  15.         {
  16.             Console.WriteLine("in");
  17.             Console.WriteLine(Math.Min(leftDistance, rightDistance));
  18.         }
  19.         else
  20.         {
  21.             Console.WriteLine("out");
  22.             Console.WriteLine(Math.Min(leftDistance, rightDistance));
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement