pesquisa

URI PROBLEMA 1015 - Distância Entre Dois Pontos EM C

URI Online Judge | 1015

Distância Entre Dois Pontos

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia os quatro valores correspondentes aos eixos x e y de dois pontos quaisquer no plano, p1(x1,y1) e p2(x2,y2) e calcule a distância entre eles, mostrando 4 casas decimais após a vírgula, segundo a fórmula:
Distancia =

Entrada

O arquivo de entrada contém duas linhas de dados. A primeira linha contém dois valores de ponto flutuante: x1 y1 e a segunda linha contém dois valores de ponto flutuante x2 y2.

Saída

Calcule e imprima o valor da distância segundo a fórmula fornecida, com 4 casas após o ponto decimal.


URI Online Judge | 1015

Distance Between Two Points

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read the four values corresponding to the x and y axes of two points in the plane, p1 (x1, y1) and p2 (x2, y2) and calculate the distance between them, showing four decimal places after the comma, according to the formula:
Distance = 

Input

The input file contains two lines of data. The first one contains two double values: x1 y1 and the second one also contains two double values with one digit after the decimal point: x2 y2.

Output

Calculate and print the distance value using the provided formula, with 4 digits after the decimal point.















#include <stdio.h>




int main() {

float x1,y1,x2,y2;

scanf("%f %f",&x1,&y1);

scanf("%f %f",&x2,&y2);

printf("%.4f\n",(sqrt(pow(x2-x1,2)+pow(y2-y1,2))));




return 0;

}

Agora que esse código te ajudou, curta esta página e indique para seus amigos. :)
Obrigado!

Postar um comentário

0 Comentários