File tree 4 files changed +92
-0
lines changed
src/main/java/com/mycompany/j04001
4 files changed +92
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
3
+ <modelVersion >4.0.0</modelVersion >
4
+ <groupId >com.mycompany</groupId >
5
+ <artifactId >J04001</artifactId >
6
+ <version >1.0-SNAPSHOT</version >
7
+ <packaging >jar</packaging >
8
+ <properties >
9
+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
10
+ <maven .compiler.source>16</maven .compiler.source>
11
+ <maven .compiler.target>16</maven .compiler.target>
12
+ </properties >
13
+ </project >
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package com .mycompany .j04001 ;
7
+
8
+ /**
9
+ *
10
+ * @author Admin
11
+ */
12
+ public class J04001 {
13
+ private double x ,y ;
14
+ public J04001 (){
15
+ }
16
+ public J04001 (double x , double y ){
17
+ this .x = x ;
18
+ this .y = y ;
19
+ }
20
+ // hàm tạo sao chép.
21
+ public J04001 (J04001 p ){
22
+ this .x = p .x ;
23
+ this .y = p .y ;
24
+ }
25
+ public double getX (){
26
+ return x ;
27
+ }
28
+ public void setX (double x ){
29
+ this .x = x ;
30
+ }
31
+ public double getY (){
32
+ return y ;
33
+ }
34
+ public void setY (double y ){
35
+ this .y = y ;
36
+ }
37
+ // taoj hamf sao chep secondpoint
38
+ public double distance (J04001 secondPoint ){
39
+ double d1 = this .x - secondPoint .x ;
40
+ double d2 = this .y - secondPoint .y ;
41
+ double dis = Math .sqrt (d1 *d1 +d2 *d2 );
42
+ return dis ;
43
+ }
44
+ public double distance (J04001 p1 , J04001 p2 ){
45
+ double d1 = p1 .x - p2 .x ;
46
+ double d2 = p1 .y - p2 .y ;
47
+ double dis = Math .sqrt (d1 *d1 + d2 *d2 );
48
+ return dis ;
49
+ }
50
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package com .mycompany .j04001 ;
7
+
8
+ /**
9
+ *
10
+ * @author Admin
11
+ */
12
+ import java .util .*;
13
+ public class Nhap {
14
+ public static void main (String [] args ) {
15
+ Scanner sc = new Scanner (System .in );
16
+ int t = sc .nextInt ();
17
+ while (t -->0 ){
18
+ J04001 P1 = new J04001 ();
19
+ J04001 P2 = new J04001 ();
20
+ P1 .setX (sc .nextDouble ());
21
+ P1 .setY (sc .nextDouble ());
22
+ P2 .setX (sc .nextDouble ());
23
+ P2 .setY (sc .nextDouble ());
24
+ double res = P1 .distance (P2 );
25
+ String s = String .format ("%.4f" ,res );
26
+ System .out .println (s );
27
+ }
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments