2 计算两点间的距离
作者: XXX时间限制: 1S章节: 顺序结构
问题描述 :
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
输入说明 :
输入数据由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。
输出说明 :
输出结果,保留两位小数。
输入范例 :3 4 -10 0
输出范例 :13.60
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
double X1,Y1,X2,Y2;
double result,X,Y;
while(scanf("%lf%lf%lf%lf",&X1,&Y1,&X2,&Y2) !=EOF) {
result = sqrt(pow((X1-X2),2)+pow((Y1-Y2),2));
printf("%.2lf",result);
}
return 0;
}