求两点间的距离
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));
}
}
}
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));
}
}
}
相关文章推荐
- CCF 201409-2 画图 题解
- SOAP的简单理解
- poj 1719 Shooting Contest
- 多级放大电路耦合方式的优缺点
- ios 动态计算文本的高度或宽度
- setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lable1.'
- Android:Tab切换方法整理
- IOS 按钮(button)用法与属性实例
- linux内核裁剪及编译可加载模块
- Linux环境下安装mysql
- 数据结构实践项目——链表
- 【Win10 应用开发】集成文件打开选择器
- ASP.NET验证控件详解
- iOS中键值编码KVC的学习
- Rythem——Mac OS下简单易用类似fiddler的抓包工具
- 如何实施敏捷开发
- kamailio服务器内容补充
- UIpickerView
- Altium Designer原理图中放置文本、图片、直线、拷贝、智能粘贴
- Android Https相关完全解析 当OkHttp遇到Https