Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Online Java Compiler
- // Use this editor to write, compile and run your Java code online
- import java.util.*;
- class HelloWorld {
- public static void main(String[] args) {
- int n = 5;
- int[] x = new int[n];
- int[] y = new int[n];
- Scanner sc = new Scanner(System.in);
- for(int i = 0 ;i < n; i++) {
- x[i] = sc.nextInt();
- y[i] = sc.nextInt();
- }
- double najkratko = 2e9;
- int A = -1, B = -1;
- for(int i = 0; i < n; i++) {
- for(int j = i + 1; j < n; j++) {
- double d = Math.sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
- if(najkratko > d) {
- najkratko = d;
- A = i;
- B = j;
- }
- }
- }
- System.out.println(najkratko + " " + A + " " + B);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement