forked from builder-of-web3/HackR_Java_Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistance bwt two point with precision
More file actions
32 lines (30 loc) · 1.12 KB
/
Distance bwt two point with precision
File metadata and controls
32 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Solution {
public static void main(String args[] ) throws Exception {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
result(line);
}
public static void result(String str) {
//System.out.println(str);
String[] splitStr = str.split("\\s+");
//System.out.println("string"+splitStr[0]);
Integer x1 = Integer.parseInt(splitStr[0]);
Integer y1 = Integer.parseInt(splitStr[1]);
Integer x2 = Integer.parseInt(splitStr[2]);
Integer y2 = Integer.parseInt(splitStr[3]);
double res = Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
DecimalFormat f = new DecimalFormat("##.000");
System.out.println(f.format(res));
}
}