(hdu 简单题 128道)hdu 2001 计算两点间的距离
来源:互联网 发布:加油站经营软件 编辑:程序博客网 时间:2024/04/30 14:15
题目:
计算两点间的距离
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 115566 Accepted Submission(s): 44177
Problem Description
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
Input
输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。
Output
对于每组输入数据,输出一行,结果保留两位小数。
Sample Input
0 0 0 10 1 1 0
Sample Output
1.001.41
Author
lcy
Source
C语言程序设计练习(一)
Recommend
JGShining | We have carefully selected several similar problems for you: 2002 2000 2010 2009 2012
题目分析:
简单题。
代码如下:
/* * g.cpp * * Created on: 2015年3月20日 * Author: Administrator hdu 2001 */#include <iostream>#include <cstdio>#include <cmath>struct PPoint{//结构体尽量不要定义成Point这种,容易和C/C++本身中的变量同名double x;double y;PPoint(double _x = 0,double _y = 0):x(_x),y(_y){}PPoint operator - (const PPoint& op2) const{return PPoint(x - op2.x,y - op2.y);}double operator^(const PPoint &op2)const{return x*op2.y - y*op2.x;}};inline double sqr(const double &x){return x*x;}inline double dis2(const PPoint &p0,const PPoint &p1){return sqr(p0.x - p1.x) + sqr(p0.y - p1.y);}inline double dis(const PPoint& p0,const PPoint& p1){return sqrt(dis2(p0,p1));}int main(){PPoint p1,p2;while(scanf("%lf %lf %lf %lf",&p1.x,&p1.y,&p2.x,&p2.y)!=EOF){printf("%.2lf\n",dis(p1,p2));}return 0;}
1 0
- (hdu 简单题 128道)hdu 2001 计算两点间的距离
- hdu 2001 计算两点间的距离
- HDU 2001 计算两点间的距离
- HDU 2001 计算两点间的距离
- HDU 2001 计算两点间的距离
- HDU 2001 - 计算两点间的距离
- HDU 2001 计算两点间的距离
- [hdu 2001] 计算两点间的距离
- HDU 2001 计算两点间的距离
- HDU 2001 计算两点间的距离
- hdu 2001 计算两点间的距离
- hdu 2001计算两点间的距离
- HDU 2001 计算两点间的距离
- HDU 2001 计算两点间的距离
- hdu 2001 计算两点间的距离
- 计算两点间的距离,hdu-2001
- hdu 2001 计算两点间的距离
- HDU-2001 计算两点间的距离
- 插入排序和归并排序实现
- Android Logcat过滤显示本应用日志信息
- 快速排序算法
- 一个tomcat部署多个struts2项目
- nginx的请求处理
- (hdu 简单题 128道)hdu 2001 计算两点间的距离
- 数据结构之迷宫问题
- poj_1159
- Ubuntu下,查看以及修改PATH的方法
- 天津回收二手数码相机
- 商业智能BI的三个层次-----数据报表、数据分析、数据挖掘
- Java三大体系Java SE,Java EE,Java EE的区别
- JIT编译器
- 两栈共享空间的顺序栈C++实现