This problem required to achieve a function, given any two points on a plane coordinate (x 1, y 1) and (x 2, y 2), find the distance between the two points .
Function interface definition:
double dist( double x1, double y1, double x2, double y2 );
Wherein the parameters passed to the user coordinates of two points (x1, y1) plane and (x2, y2), the distance between two points dist function should return.
Referee test program Example:
#include <stdio.h>
#include <math.h>
double dist( double x1, double y1, double x2, double y2 );
int main()
{
double x1, y1, x2, y2;
scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
printf("dist = %.2f\n", dist(x1, y1, x2, y2));
return 0;
}
/* 你的代码将被嵌在这里 */
Sample input:
10 10 200 100
Sample output:
dist = 210.24
double dist( double x1, double y1, double x2, double y2 )
{
double i,j,s;
i=(x1-x2)*(x1-x2);
j=(y1-y2)*(y1-y2);
s=pow(i+j,0.5);
return s;
}