您的位置:首页 > 其它

求两点间的距离

2015-09-12 11:28 218 查看
package OJ;

import java.text.DecimalFormat;

import java.util.*;

public class Bully {

/*


  * */

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(sc.hasNext()){
String str = sc.nextLine();
String[] s = str.split(" ");
int x1 = Integer.parseInt(s[0]);
int y1 = Integer.parseInt(s[1]);
int x2 = Integer.parseInt(s[2]);
int y2 = Integer.parseInt(s[3]);

double sum = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
double re = Math.sqrt(sum);

DecimalFormat df = new DecimalFormat("0.00");

System.out.println(df.format(re));
}

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: