Advertisement
KechevD

Points

Apr 22nd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4.  
  5. public class PointInRange {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner = new Scanner(System.in);
  10.  
  11.  
  12.  
  13.         int n = Integer.parseInt(scanner.nextLine());
  14.  
  15.  
  16.  
  17.         double minDistance = Double.MAX_VALUE;
  18.  
  19.  
  20.  
  21.         for (int i = 0; i < n; i++) {
  22.  
  23.  
  24.  
  25.             String[] point1 = scanner.nextLine().split(",");
  26.  
  27.             String[] point2 = scanner.nextLine().split(",");
  28.  
  29.  
  30.  
  31.             int x1 = Integer.parseInt(point1[0]);
  32.  
  33.             int y1 = Integer.parseInt(point1[1]);
  34.  
  35.  
  36.  
  37.             int x2 = Integer.parseInt(point2[0]);
  38.  
  39.             int y2 = Integer.parseInt(point2[1]);
  40.  
  41.  
  42.  
  43.             double d = Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
  44.  
  45.  
  46.  
  47.             System.out.println(String.format("%.2f",d));
  48.  
  49.  
  50.  
  51.             if (minDistance<d){
  52.  
  53.                 minDistance = d;
  54.  
  55.             }
  56.  
  57.         }
  58.  
  59.  
  60.  
  61.         System.out.printf("Min Distance: %.2f",minDistance);
  62.  
  63.  
  64.  
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement