-
Notifications
You must be signed in to change notification settings - Fork 1
/
KhaiBaoLopPoint.java
57 lines (49 loc) · 1.34 KB
/
KhaiBaoLopPoint.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package codeptit;
/**
*
* @author Administrator
*/
import java.io.*;
import java.util.*;
import java.math.*;
class Point{
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
public class KhaiBaoLopPoint {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0){
double x1 =sc.nextDouble();
double y1 =sc.nextDouble();
double x2 =sc.nextDouble();
double y2 =sc.nextDouble();
Point a = new Point(x1, y1);
Point b = new Point(x2, y2);
double res = (a.getX() - b.getX())*(a.getX() - b.getX())
+ (a.getY() - b.getY())*(a.getY() - b.getY());
System.out.printf("%.4f\n", Math.sqrt(res));
}
}
}