ztse9172 @ 2024-12-26 21:12:37
#include<bits/stdc++.h>
using namespace std;
double d(double x1, double y1, double x2, double y2)
{
return sqrt(abs((x1 - x2) * (x1 - x2)) + abs((y1 - y2) * (y1 - y2)));
}
int main(){
int x1,y1,x2,y2,x3,y3;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
double d1 = d(x1, y1, x2, y2) ;
double d2 =d(x2,y2,x3,y3);
double d3=d(x1,y1,x3,y3);
double c = d1 + d2 + d3;
cout<<fixed<<setprecision(2)<<c;
}
by LionBlaze @ 2024-12-26 21:16:36
@ztse9172 坐标值是实数
验证码 CP32 寄
by a11223344 @ 2024-12-26 21:16:39
输入的坐标是实数,所以x1,y1,x2,y2,x3,y3应定义为double类型而不是int
by ztse9172 @ 2024-12-27 17:45:19
@LionBlaze@LionBlaze@a11223344 谢谢