Advertisement
YavorJS

point over segment

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