Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace To4kaVarhuOtse4ka_PointOnSegment_
- {
- class Program
- {
- static void Main(string[] args)
- {
- var firstNum = int.Parse(Console.ReadLine());
- var secondNum = int.Parse(Console.ReadLine());
- var point = int.Parse(Console.ReadLine());
- var firstP = 0;
- var secondP = 0;
- var secondDiff = 0;
- var firstDiff = 0;
- if (firstNum<secondNum)
- {
- firstP = firstNum;
- secondP = secondNum;
- }
- else
- {
- firstP = secondNum;
- secondP = firstNum;
- }
- if (point>=firstP&&point<=secondP)
- {
- Console.WriteLine("in");
- secondDiff = secondP - point;
- firstDiff = point - firstP;
- if (firstDiff>secondDiff)
- {
- Console.WriteLine(secondDiff);
- }
- else
- {
- Console.WriteLine(firstDiff);
- }
- }
- if (point<firstP || point>secondP)
- {
- Console.WriteLine("out");
- secondDiff = Math.Abs(secondP - point);
- firstDiff = Math.Abs(point - firstP);
- if (firstDiff>secondDiff)
- {
- Console.WriteLine(secondDiff);
- }
- else
- {
- Console.WriteLine(firstDiff);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement