Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 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 PointOnSegment
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int first = int.Parse(Console.ReadLine());
  14. int second = int.Parse(Console.ReadLine());
  15. if (first > second)
  16. {
  17. var c = first;
  18. first = second;
  19. second = c;
  20. }
  21. int point = int.Parse(Console.ReadLine());
  22. if (point >= first && point <= second)
  23. {
  24. Console.WriteLine("in");
  25. }
  26. else
  27. {
  28. Console.WriteLine("out");
  29. }
  30. int pointDistFirst = Math.Abs(first - point);
  31. int pointDistSecond = Math.Abs(second - point);
  32. if (pointDistFirst < pointDistSecond)
  33. {
  34. Console.WriteLine(pointDistFirst);
  35. }
  36. else
  37. {
  38. Console.WriteLine(pointDistSecond);
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement