Advertisement
tmollov

Untitled

Dec 17th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PointOnSegment
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int firstNumber = int.Parse(Console.ReadLine());
  10. int secondNumber = int.Parse(Console.ReadLine());
  11. int firstPoint = 0;
  12. int secondPoint = 0;
  13. if (firstNumber > secondNumber)
  14. {
  15. secondPoint = firstNumber;
  16. firstPoint = secondNumber;
  17. }
  18. else
  19. {
  20. secondPoint = secondNumber;
  21. firstPoint = firstNumber;
  22. }
  23.  
  24. int point = int.Parse(Console.ReadLine());
  25. int CheckNum = firstPoint - point < secondPoint - point ? firstPoint : secondPoint;
  26. if (point >= firstPoint && point <= secondPoint)
  27. {
  28. Console.WriteLine("in");
  29. }
  30. else
  31. {
  32. Console.WriteLine("out");
  33. }
  34.  
  35. if (point >= secondPoint)
  36. {
  37. Console.WriteLine(Math.Abs(point - secondPoint));
  38. }
  39. else if (point <= firstPoint)
  40. {
  41. Console.WriteLine(Math.Abs(firstPoint - point));
  42.  
  43. }
  44. else
  45. {
  46. Console.WriteLine(Math.Abs(CheckNum - point));
  47. }
  48.  
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement