浮点数x保留一位小数的技巧:x = (int)(10.0*x+-0.5) / 10.0(x为正则加,x为负则减)
#include<cstdio>
#include<cmath>
int main()
{
double x1,y1;
double x2,y2;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
//保留一位小数(会报错,因为无法确定正负,不能确定是+/-0.5)
//x1=(int)(10.0*x1+0.5)/10.0;
//x2=(int)(10.0*x2+0.5)/10.0;
//y1=(int)(10.0*y1+0.5)/10.0;
//y2=(int)(10.0*y2+0.5)/10.0;
printf("%.4lf\n",sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
return 0;
}