Advertisement
Guest User

Untitled

a guest
Jan 25th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Point_on_Segment_Loop
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var first = int.Parse(Console.ReadLine());
  14.             var second = int.Parse(Console.ReadLine());
  15.             var point = int.Parse(Console.ReadLine());
  16.  
  17.             var minNum = Math.Min(first, second);
  18.             var maxNum = Math.Max(first, second);
  19.             bool pointIsIn = false;
  20.  
  21.             for (int i = minNum; i <= maxNum; i++)
  22.             {
  23.                 if (point == i)
  24.                 {
  25.                     pointIsIn = true;
  26.                     break;
  27.                 }
  28.             }
  29.             if (pointIsIn)
  30.             {
  31.                 Console.WriteLine("in");
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine("out");
  36.             }
  37.  
  38.             var difference = Math.Min(Math.Abs(point - first), Math.Abs(point - second));
  39.  
  40.             Console.WriteLine(difference);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement