sm11e @ 2023-09-29 12:42:33
#include<iostream>
#include<cmath>
using namespace std;
int dis(int e, int d);
int main()
{
double x1, x2, x3, y4, y2, y3;
cin >> x1 >> y4;
cin >> x2 >> y2;
cin >> x3 >> y3;
double X1 = abs(x1 - x2);
double X2 = abs(x1 - x3);
double X3 = abs(x2 - x3);
double Y1 = abs(y4 - y2);
double Y2 = abs(y4 - y3);
double Y3 = abs(y2 - y3);
double c1, c2, c3, c4;
c1 = dis(X1, Y1);
c2 = dis(X2, Y2);
c3 = dis(X3, Y3);
c4 = c1 + c2 + c3;
printf("%.2lf", c4);
return 0;
}
int dis(int e,int d)
{
int c;
c = sqrt((e * e) + (d * d));
return c;
}
by Cindy_Li @ 2023-09-29 12:49:54
你的 dis 函数返回的是 int
实际上显然应该返回 double
by sm11e @ 2023-09-29 12:55:52
@Cindy_Li 这样啊,谢谢