2001

来源:互联网 发布:系统重装后c盘数据恢复 编辑:程序博客网 时间:2024/04/30 01:19


这道题重点在于数值的处理   用了cout.precision(2)来保证精度 以及fixed的强制转换

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
 double x1,y1,x2,y2,d;
 while(cin>>x1>>y1>>x2>>y2)
{
 d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
 cout.precision(2);
 cout<<fixed<<d<<endl;


}
return 0;



}

0 0