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 _03_Point_on_Segment
- {
- class Program
- {
- static void Main(string[] args)
- {
- var first = double.Parse(Console.ReadLine());
- var second = double.Parse(Console.ReadLine());
- var point = double.Parse(Console.ReadLine());
- var middle = (first + second) / 2; // намира средната стойност в интервала между first и second числото на абцисната ос x.
- // обратна абцица
- if (first >= point && point >= second)
- {
- if (middle > point)
- {
- var distance = point - second;
- Console.WriteLine("in {0}", distance);
- }
- else if (point > middle)
- {
- var distance = first - point;
- Console.WriteLine("in {0}", distance);
- }
- }
- else
- {
- if (point > first)
- {
- var distance = point - first;
- Console.WriteLine("out {0}", distance);
- }
- else if (second > point)
- {
- var distance = second - point;
- Console.WriteLine("out {0}", distance);
- }
- }
- // край
- // права абциса
- if (first <= point && point <= second)
- {
- if (point < middle)
- {
- var distance = point - first;
- Console.WriteLine("in {0}", distance);
- }
- else if (point > middle)
- {
- var distance = second - point;
- Console.WriteLine("in {0}", distance);
- }
- }
- else
- {
- if (point > second)
- {
- var distance = point - second;
- Console.WriteLine("out {0}", distance);
- }
- else if (first > point)
- {
- var distance = first - point;
- Console.WriteLine("out {0}", distance);
- }
- }
- // край
- // */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement