S1P1 - Calculate Distance
Mohamed loves Travelling. but as travelling take a lot of time from him. He needs your help to calculate the distance between his current location and location of the place he wants to go. Location of each place will be given in (x, y) coordinates.
Input
Input will be 4 doubles x1, y1, x2, y2 represent two locations (Mohamed's current location, location of the place he wants to go to.)
Where 0 <= x1, y1, x2, y2 <= 10000.
Output
Print distance between 2 locations as "Euclidean distance".
Print a newline after each test case.
Example
Input: 0 2 4 6 Output: 5.65685
Please note:
You can find "Euclidean distance" formula in http://www.cut-the-knot.org/pythagoras/DistanceFormula.shtml.
you can use sqrt() function to get square root. sqrt() take a double or a float number for example
cout << sqrt(4.0) << endl; // will print 2.0
And to use sqrt() function please include cmath library. Just put #include <cmath> in you code.
hide comments
dsr:
2015-03-28 09:15:29
Why the restriction to use only C++?
|
|
Samil Vargas:
2013-12-25 18:19:56
Thanks for all the info mohamed you make it easy
|
Added by: | mohamed gamal |
Date: | 2012-01-27 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C++ 4.3.2 CPP |