Advertisement
Sim0o0na

Untitled

Dec 18th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 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 To4kaVarhuOtse4ka_PointOnSegment_
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var firstNum = int.Parse(Console.ReadLine());
  14.             var secondNum = int.Parse(Console.ReadLine());
  15.             var point = int.Parse(Console.ReadLine());
  16.  
  17.             var firstP = 0;
  18.             var secondP = 0;
  19.  
  20.             var secondDiff = 0;
  21.             var firstDiff = 0;
  22.             if (firstNum<secondNum)
  23.             {
  24.                 firstP = firstNum;
  25.                 secondP = secondNum;
  26.             }
  27.             else
  28.             {
  29.                 firstP = secondNum;
  30.                 secondP = firstNum;
  31.             }
  32.             if (point>=firstP&&point<=secondP)
  33.             {
  34.                 Console.WriteLine("in");
  35.                 secondDiff = secondP - point;
  36.                 firstDiff = point - firstP;
  37.  
  38.                 if (firstDiff>secondDiff)
  39.                 {
  40.                     Console.WriteLine(secondDiff);
  41.                 }
  42.                 else
  43.                 {
  44.                     Console.WriteLine(firstDiff);
  45.                 }
  46.             }
  47.             if (point<firstP || point>secondP)
  48.             {
  49.                 Console.WriteLine("out");
  50.                 secondDiff = Math.Abs(secondP - point);
  51.                 firstDiff = Math.Abs(point - firstP);
  52.                 if (firstDiff>secondDiff)
  53.                 {
  54.                     Console.WriteLine(secondDiff);
  55.                 }
  56.                 else
  57.                 {
  58.                     Console.WriteLine(firstDiff);
  59.                 }
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement