Skip to content

Commit 8139da4

Browse files
author
lanyuanxiaoyao
committed
修改文件: _posts/2014-09-10-caculate-two-point.md
1 parent a1c78eb commit 8139da4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
layout: post
3+
title: 2001.计算两点间的距离
4+
date: 2014-09-10 17:03
5+
categories: 杭电HDU
6+
tags: [杭电HDU]
7+
---
8+
## Problem
9+
>**Problem Description**
10+
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
11+
**Input**
12+
输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。
13+
**Output**
14+
对于每组输入数据,输出一行,结果保留两位小数。
15+
**Sample Input**
16+
0 0 0 1
17+
0 1 1 0
18+
**Sample Output**
19+
1.00
20+
1.41
21+
22+
## Solution
23+
```cpp
24+
#include<stdio.h>
25+
#include<math.h>
26+
int main(void)
27+
{
28+
float x1,y1,x2,y2,line;
29+
30+
while(scanf("%f %f %f %f",&x1,&y1,&x2,&y2)!=EOF){
31+
line=sqrt(pow((x1-x2),2)+pow((y1-y2),2));
32+
printf("%.2f\n",line);
33+
}
34+
return 0;
35+
}
36+
```

0 commit comments

Comments
 (0)