1062. Calculate the Manhattan distance, 1062 calculate the Manhattan distance
The question description shows the coordinates (x1, y1), (x2, y2) of the two points on the plane, and calculates the Manhattan distance between the two points. Manhattan distance = | x1-x2 | + | y1-y2 |. Enter the real numbers separated by four spaces in a row, representing x1, y1, x2, y2, respectively. Output a real number to indicate the Manhattan distance and retain three decimal places. Sample Input
Output a real number to indicate the Manhattan distance and retain three decimal places.
Sample output
3.600
Data range:-10000 <= x1, y1, x2, y2 <= 10000
1 # include <iostream> 2 # include <cstring> 3 # include <cmath> 4 # include <cstdio> 5 using namespace std; 6 int main () 7 {8 double x1, x2, y1, y2; 9 cin> x1> y1> x2> y2; 10 printf ("%. 3lf ", abs (x1-x2) + abs (y1-y2); 11 return 0; 12}