Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PointInRange {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- double minDistance = Double.MAX_VALUE;
- for (int i = 0; i < n; i++) {
- String[] point1 = scanner.nextLine().split(",");
- String[] point2 = scanner.nextLine().split(",");
- int x1 = Integer.parseInt(point1[0]);
- int y1 = Integer.parseInt(point1[1]);
- int x2 = Integer.parseInt(point2[0]);
- int y2 = Integer.parseInt(point2[1]);
- double d = Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
- System.out.println(String.format("%.2f",d));
- if (minDistance<d){
- minDistance = d;
- }
- }
- System.out.printf("Min Distance: %.2f",minDistance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement