码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 2001 (水)

时间:2018-07-23 22:08:11      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:基本   mes   Fix   stream   int   target   命名空间   get   set   

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2001

题目大意:两个点求距离

解题思路:

套基本公式 a = √(b2 + c2);

小数点后几位的表示方法,用std命名空间中常见的的流控制符,用到setprecision函数和<iomanip>头文件,fixed是非科学记数法的普通表示;

ax == pow(a, x);

pow(),sqrt()均在<math>里

代码:

#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
    double a, b, c, d;
    while(cin >> a >> b >> c >> d)
    {
        cout << fixed << setprecision(2) << sqrt((a-c)*(a-c) + (b-d)*(b-d)) << endl;
    }

}

 

HDU 2001 (水)

标签:基本   mes   Fix   stream   int   target   命名空间   get   set   

原文地址:https://www.cnblogs.com/mimangdewo-a1/p/9356942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!