Euclidean Distance Between Two Points
Marlow Robotics runs picking robots across a flat warehouse floor. Every shelf and every charging dock is stored as a pair of floor coordinates in metres. A robot crosses open floor in a straight line — nothing stands in its way — so the planner needs the straight-line separation between two recorded spots, not the distance a trolley would cover pushed along the aisles.
Task: Print the straight-line distance between the two points.
Input
One line holding four numbers separated by single spaces: x1 y1 x2 y2. The first two numbers are the coordinates of one point; the last two are the coordinates of the other. Numbers may be negative and may have a decimal part.
Output
One line holding the distance, written with exactly 4 digits after the decimal point. Keep the trailing zeros — a distance of five prints as 5.0000, never 5.0.
Example:
Input:
0 0 3 4
Output:
5.0000
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in