杭电oj编码2001
来源:互联网 发布:软件出售 编辑:程序博客网 时间:2024/06/14 06:03
问题描述:
输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。
输入:
输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。
输出:
对于每组输入数据,输出一行,结果保留两位小数。
样例输入:
0 0 0 1
0 1 1 0
样例输出:
1.00
1.41
分析:
需要用到数学公式:
代码:
#include<iostream>#include<cmath>#include<stdio.h>int main(){double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;while (std::cin >> x1 >> y1 >> x2 >> y2){double reslut;reslut = sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));printf("%.2lf\n", reslut);}return 0;}
0 0
- 杭电oj编码2001
- 杭电OJ编码1000
- 杭电OJ编码1001
- 杭电OJ编码1002
- 杭电OJ编码1994
- 杭电oj编码2014
- 杭电oj编码2013
- 杭电oj编码2012
- 杭电oj编码2011
- 杭电oj编码2015
- 杭电oj编码2016
- 杭电oj编码2018
- 杭电oj编码2019
- 杭电oj编码2020
- 杭电oj编码2010
- 杭电oj编码2009
- 杭电oj编码2021
- 杭电oj编码2022
- 归并排序(Merge Sort)
- 杭电oj编码2003
- c++函数的几种关系
- 杭电oj编码2002
- 基数排序(Radix)
- 杭电oj编码2001
- 用window.name来解决不同网页间的数据通信
- 杭电oj编码2000
- 工具函数之取数组的topN和bottomN
- 工具函数之取数组中的最值和最优值
- HDU 1102 Constructing Roads【最小生成树】
- 算法时间复杂度的表示
- 排序算法: 时间复杂度、空间复杂度、稳定性总结
- Android学习不容错过的Blog