(URI) Distância Entre Dois Pontos - Solução
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String linha = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(linha);
double x1 = Double.parseDouble(tokenizer.nextToken());
double y1 = Double.parseDouble(tokenizer.nextToken());
linha = br.readLine();
tokenizer = new StringTokenizer(linha);
double x2 = Double.parseDouble(tokenizer.nextToken());
double y2 = Double.parseDouble(tokenizer.nextToken());
double distancia = Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
System.out.printf("%.4f\n", distancia);
}
}
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String linha = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(linha);
double x1 = Double.parseDouble(tokenizer.nextToken());
double y1 = Double.parseDouble(tokenizer.nextToken());
linha = br.readLine();
tokenizer = new StringTokenizer(linha);
double x2 = Double.parseDouble(tokenizer.nextToken());
double y2 = Double.parseDouble(tokenizer.nextToken());
double distancia = Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
System.out.printf("%.4f\n", distancia);
}
}
Comments
Post a Comment