1118: 零起点学算法25——求两点之间的距离
1118: 零起点学算法25——求两点之间的距离
Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 3183 Accepted: 1975
[Submit][Status][Web Board]
Description
输入平面坐标系中2点的坐标,输出它们之间的距离
Input
输入4个浮点数x1 y1 x2 y2,分别是点(x1,y1) (x2,y2)的坐标(多组数据)
Output
输出它们之间的距离,保留2位小数(每组数据一行)
Sample Input
1 0 2 0
Sample Output
1.00
Source
1 #include<stdio.h> 2 #include<math.h> 3 int main(){ 4 double x1,y1,x2,y2; 5 while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF){ 6 printf("%.2f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); 7 } 8 return 0; 9 }