1. 程式人生 > 其它 >【ACWing】616. 兩點間的距離

【ACWing】616. 兩點間的距離

技術標籤:AC 陣列、連結串列與模擬

題目地址:

https://www.acwing.com/problem/content/618/

給定平面兩個點座標,求其歐幾里得距離。保留四位小數。

程式碼如下:

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.4lf\n",
sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))); return 0; }

時空複雜度 O ( 1 ) O(1) O(1)