2: 计算两点间的距离

2 计算两点间的距离

作者: XXX时间限制: 1S章节: 顺序结构

问题描述 :
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。

输入说明 :
输入数据由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。

输出说明 :
输出结果,保留两位小数。

输入范例 :
3 4 -10 0
输出范例 :
13.60

代码:

#include <stdio.h>
#include <math.h>
int main()
{
	double x1, y1, x2, y2;
	double l1,L;
	while (scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != EOF)
	{
		l1 = pow((x2 - x1), 2.0) + pow((y2 - y1), 2.0);
		L = sqrt(l1);
		printf("%.2lf", L);
		printf("
");
	}
        return 0;
}
Yesterday is history,tomorrow ismystery,but today is a gift!That why it is called Present!
原文地址:https://www.cnblogs.com/VictorierJwr/p/12242163.html