java比較大小方法 java求兩點(diǎn)距離?
java求兩點(diǎn)距離?public class Point{private double x private double y public Point(double x,double y){this.
java求兩點(diǎn)距離?
public class Point{private double x private double y public Point(double x,double y){this.x=x this.y=y}public double getDistance(Point p){doubleu x=數(shù)學(xué).abs(this.x-p.x)doubleu y=數(shù)學(xué).abs(this.y-p.y)返回?cái)?shù)學(xué).sqrt(u x*u xu y*u y)}公共靜態(tài)void main(String[]args){Point p1=new Point(5,5)Point p2=new點(diǎn)(10,10)系統(tǒng)輸出打?。╬2.getDistance(p1))}
公共類(lèi)點(diǎn){
雙x1,x2,y1,y2
雙d,x3,y3
點(diǎn)(雙x1,雙y1,雙x2,雙y2){//測(cè)試點(diǎn)(){//x3=(x1 x2)/2
y3=(y1 y2)/2
d=數(shù)學(xué).sqrt((x1-x2)*(x1-x2)(y1-y2)*(y1-y2))系統(tǒng)輸出打?。ā埃ā眡3“,”y3“)”)系統(tǒng)輸出打印(d)
}
public static void main(String[]args){
Point p=new點(diǎn)(1,1,2,2)(y1-y2)2)2)2)2)2)2)2)2)2)2)2)2)2)2)2)2
;2(y1-y2)2)2)2)2)2
;2)2)2)2(2)2
;2)2;2)2;2)2;2)2;3)2(4)2)2(2)2)2
;4(28982)2、2、2、2、2、2、3、3、3、3、3、3、3、3、8、3、3、3、3、3、3)3、3、3、3、3、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、2、是的,是的