Commit d573f271 by Believer Programmers' Club

### Merge branch 'branch6.48' into 'master'

```michael.davityan:exercise_06_48v2

See merge request bpcarm/trainings2017!1363```
parents e6a8a082 1c8eaa2c
 The distance between to points is. 6.32456 The distance between two points is: 6.32456
 The distance between to points is. 7.07107 The distance between two points is: 7.07107
 The distance between to points is. 15.6205 The distance between two points is: 15.6205
 The distance between to points is. 13.4536 The distance between two points is: 13.4536
 The distance between to points is. 0 The distance between two points is: 0
 ... ... @@ -27,32 +27,16 @@ main() } double y2; std::cin >> y2; std::cout << "The distance between to points is. " << distanceBetweenTwoPoints(x1, y1, x2, y2) << std::endl; std::cout << "The distance between two points is: " << distanceBetweenTwoPoints(x1, y1, x2, y2) << std::endl; return 0; } double distanceBetweenTwoPoints(const double x1, const double y1, const double x2, const double y2) { double xCordinatsSumm; double x1Absolute = std::abs(x1); double x2Absolute = std::abs(x2); if (((x1 <= 0) && (x2 <= 0)) || ((x1 >= 0) && (x2 >= 0))) { xCordinatsSumm = std::abs(x2Absolute - x1Absolute); } else if (((x1 < 0) && (x2 > 0)) || ((x1 > 0) && (x2 < 0))) { xCordinatsSumm = x2Absolute + x1Absolute; } double yCordinatsSumm; double y1Absolute = std::abs(y1); double y2Absolute = std::abs(y2); if (((y1 <= 0) && (y2 <= 0)) || ((y1 >= 0) && (y2 >= 0))) { yCordinatsSumm = std::abs(y2Absolute - y1Absolute); } else if (((y1 < 0) && (y2 > 0)) || ((y1 > 0) && (y2 < 0))) { yCordinatsSumm = y2Absolute + y1Absolute; } double distance = std::sqrt(xCordinatsSumm * xCordinatsSumm + yCordinatsSumm * yCordinatsSumm); double xCordinatsDifference = x2 - x1; double yCordinatsDifference = y2 - y1; double distance = std::sqrt(xCordinatsDifference * xCordinatsDifference + yCordinatsDifference * yCordinatsDifference); return distance; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!