80分,哪位大佬帮忙看看,会关注

P5735 【深基7.例1】距离函数

sweet_520 @ 2024-11-28 14:30:43

#include<iostream>
#include<cmath>
using namespace std;
#include<vector>
typedef pair <double, double> PII;
double len(PII x, PII y, PII z)
{
    long long  c = 0, k = 0, c1, k1, c2, k2;
    c = abs(x.first - y.first);
    k = abs(x.second - y.second);
    c1 = abs(x.first - z.first);
    k1 = abs(x.second - z.second);
    c2 = abs(y.first - z.first);
    k2 = abs(y.second - z.second);
    return sqrt(c * c + k * k) + sqrt(c1 * c1 + k1 * k1) + sqrt(c2 * c2 + k2 * k2);
}
int main()
{
    PII x, y, z;
    cin >> x.first >> x.second;
    cin >> y.first >> y.second;
    cin >> z.first >> z.second;
    printf("%.2f", len(x, y, z));
}

by Ff472130 @ 2024-11-28 14:36:56

第八行把longlong改成double


by Ff472130 @ 2024-11-28 14:39:00

@sweet_520


by sweet_520 @ 2024-11-28 14:45:25

@Ff472130谢谢,一直没看出来,非常感谢


|