wkl20110514 @ 2023-06-24 12:32:38
第五组样例:
23.234 12.123
-99.99 99.99
-1 -100
样例输出:
489.20
我的输出:
489.20
我的代码:
#include<cstdio>
#include<algorithm>
#include<cmath>
double A;
struct xy {
double x;
double y;
};
double dis(double x, double y, double x1, double y1, double x2, double y2) {
return sqrt(pow(abs(x - x1), 2) + pow(abs(y - y1), 2)) + sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2)) + sqrt(pow(abs(x2 - x), 2) + pow(abs(y2 - y), 2));
}
int main() {
xy a, b, c;
scanf("%lf %lf\n%lf %lf\n%lf %lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y);
A = dis(a.x, a.y, b.x, b.y, c.x, c.y);
if (floor(A) == A)printf("%d", int(A));
else if (floor(A * 10) == A * 10)printf("%.1lf", A);
else printf("%.2lf", A);
return 0;
}
by xiaofeng_and_xiaoyu @ 2023-06-24 12:36:04
你的结果是
by codejiahui @ 2023-06-24 12:36:26
@wkl20110514 你的输出是487.02吧?
by wkl20110514 @ 2023-06-24 12:38:36
@xiaofeng_and_xiaoyu 额,但真的是489.20
by graspppp @ 2023-06-24 12:43:23
您是否重新编译了
by wkl20110514 @ 2023-06-24 12:50:19
@graspppp 啊,对的,谢谢