> For the complete documentation index, see [llms.txt](https://xtecna.gitbook.io/solucoes-da-beecrowd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xtecna.gitbook.io/solucoes-da-beecrowd/iniciante/1015-distancia-entre-dois-pontos.md).

# 1015 - Distância Entre Dois Pontos

## Descrição

{% embed url="<https://www.urionlinejudge.com.br/judge/pt/problems/view/1015>" %}

## Solução

Aplicação direta da fórmula apresentada no enunciado. Para a maioria das linguagens, é necessário recorrer a uma biblioteca externa para usar a operação da raiz quadrada.

{% tabs %}
{% tab title="C99" %}

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

int main(){
    double x1, y1, x2, y2, distancia;

    scanf("%lf %lf\n%lf %lf", &x1, &y1, &x2, &y2);

    distancia = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));

    printf("%.4lf\n", distancia);

    return 0;
}
```

{% endtab %}

{% tab title="C++17" %}

```cpp
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
    double x1, y1, x2, y2, distancia;

    cin >> x1 >> y1 >> x2 >> y2;

    distancia = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));

    cout << setprecision(4) << fixed << distancia << endl;

    return 0;
}
```

{% endtab %}

{% tab title="JavaScript 12.18" %}

```javascript
let input = require("fs").readFileSync("/dev/stdin", "utf8");
let lines = input.split("\n");

let [x1, y1] = lines.shift().split(" ").map((x) => parseFloat(x));
let [x2, y2] = lines.shift().split(" ").map((x) => parseFloat(x));

let distancia = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

console.log(distancia.toFixed(4));
```

{% endtab %}

{% tab title="Python 3.9" %}

```python
import math

x1, y1 = [float(x) for x in input().split(' ')]
x2, y2 = [float(x) for x in input().split(' ')]

distancia = math.sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))

print(f"{distancia:.4f}")
```

{% endtab %}
{% endtabs %}
