Description
编一程序,求两点之间的距离。已知直角坐标系中两点(x1,y1)和 (x2,y2),公式求取两点间距离。
Input
输入仅一行,输入4个任意数(2个坐标点的横纵坐标值)x1,y1;x2,y2
Output
输出仅一行,输出两点间距离值。
Sample Input
0 0 1 1(x1=0,y1=0;x2=1,y2=1)
Sample Output
1.414214
#include<stdio.h>
#include<math.h>
int main()
{
float x1,y1,x2,y2,a,b,c;
scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
a=x2-x1;b=y2-y1;
c=a*a+b*b;
c=pow(c, 0.5);
printf("%f",c);
}