Advertisement
Boris-Stavrev92

Untitled

Feb 23rd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 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 _03_Point_on_Segment
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var first = double.Parse(Console.ReadLine());
  14.  
  15. var second = double.Parse(Console.ReadLine());
  16.  
  17. var point = double.Parse(Console.ReadLine());
  18.  
  19.  
  20.  
  21. var middle = (first + second) / 2; // намира средната стойност в интервала между first и second числото на абцисната ос x.
  22.  
  23. // обратна абцица
  24.  
  25. if (first >= point && point >= second)
  26. {
  27. if (middle > point)
  28. {
  29. var distance = point - second;
  30. Console.WriteLine("in {0}", distance);
  31. }
  32. else if (point > middle)
  33. {
  34. var distance = first - point;
  35. Console.WriteLine("in {0}", distance);
  36. }
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. }
  45.  
  46. else
  47. {
  48.  
  49. if (point > first)
  50. {
  51. var distance = point - first;
  52. Console.WriteLine("out {0}", distance);
  53. }
  54.  
  55. else if (second > point)
  56. {
  57. var distance = second - point;
  58. Console.WriteLine("out {0}", distance);
  59. }
  60.  
  61.  
  62. }
  63.  
  64. // край
  65.  
  66.  
  67. // права абциса
  68.  
  69. if (first <= point && point <= second)
  70. {
  71. if (point < middle)
  72. {
  73. var distance = point - first;
  74. Console.WriteLine("in {0}", distance);
  75. }
  76. else if (point > middle)
  77. {
  78. var distance = second - point;
  79. Console.WriteLine("in {0}", distance);
  80. }
  81.  
  82. }
  83.  
  84. else
  85. {
  86.  
  87. if (point > second)
  88. {
  89. var distance = point - second;
  90. Console.WriteLine("out {0}", distance);
  91. }
  92.  
  93. else if (first > point)
  94. {
  95. var distance = first - point;
  96. Console.WriteLine("out {0}", distance);
  97. }
  98.  
  99.  
  100. }
  101.  
  102. // край
  103.  
  104.  
  105. // */
  106.  
  107. }
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement