360oj 輸入兩點座標(X1,Y1),(X2,Y2),計算並輸出兩點間的距離。

Problem Description
輸入兩點座標(X1,Y1),(X2,Y2),計算並輸出兩點間的距離。
Input
輸入數據有多組,每組佔一行,由4個實數組成,分別表示x1,y1,x2,y2,數據之間用空格隔開。
Output
對於每組輸入數據,輸出一行,結果保留兩位小數。
Sample Input
0 0 0 1
0 1 1 0
Sample Output
1.00
1.41

#include <stdio.h>
#include <math.h>

int main()
{
 double x1,y1,x2,y2;
 while(EOF != scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2))
 {
  printf("%.2f",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
 }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章