URI ONLINE JUDGE SOLUTION 1015 - Distance Between Two Points

Problem:

Read the four values corresponding to the x and y axes of two points in the plane, p1 (x1, y1) and p2 (x2, y2) and calculate the distance between them, showing four decimal places after the comma, according to the formula:

Distance =

Input

The input file contains two lines of data. The first one contains two double values: x1 y1 and the second one also contains two double values with one digit after the decimal point: x2 y2.

Output


Calculate and print the distance value using the provided formula, with 4 digits after the decimal point.


Solution:

#include<stdio.h>
#include<math.h>
int main()
{
    double x1,x2,y1,y2,dis;
    scanf("%lf%lf%lf%lf",&x1,&x2,&y1,&y2);
    dis=sqrt(pow((y1-x1),2)+pow((y2-x2),2));
    printf("%0.4lf\n",dis);
    return 0;

}

Comments

Popular posts from this blog

URI ONLINE JUDGE SOLUTION 1021 - Banknotes and Coins

URI ONLINE JUDGE SOLUTION 1040 - Average 3

URI ONLINE JUDGE SOLUTION 1036 - Bhaskara's Formula