SHARE
TWEET

Untitled

a guest Apr 22nd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class PointInRange {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         double minDistance = Double.MAX_VALUE;
  10.  
  11.         for (int i = 0; i < n; i++) {
  12.  
  13.             String[] point1 = scanner.nextLine().split(",");
  14.             String[] point2 = scanner.nextLine().split(",");
  15.  
  16.             int x1 = Integer.parseInt(point1[0]);
  17.             int y1 = Integer.parseInt(point1[1]);
  18.  
  19.             int x2 = Integer.parseInt(point2[0]);
  20.             int y2 = Integer.parseInt(point2[1]);
  21.  
  22.             double d = Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
  23.  
  24.             System.out.println(String.format("%.2f",d));
  25.  
  26.             if (minDistance<d){
  27.                 minDistance = d;
  28.             }
  29.         }
  30.  
  31.         System.out.printf("Min Distance: %.2f",minDistance);
  32.  
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top