题目描述
已知两点的坐标,求两点间的距离。
输入
两行,两点的坐标,中间用空格隔开
输出
它们之间的距离,保留两位小数
样例输入
1 1
2 2
样例输出
1.41
#include <stdio.h>
#include <math.h>
struct point
{
double x;
double y;
};
struct point p[10];
int main()
{
scanf("%lf %lf",&p[0].x,&p[0].y);
scanf("%lf %lf",&p[1].x,&p[1].y);
double a=p[0].x-p[1].x;
double b=p[0].y-p[1].y;
double d=sqrt(a*a+b*b);
printf("%.2lf",d);
return 0;
}