为撒子错啊,dalao们看看行吗

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

yisongqingyu @ 2021-10-21 21:04:48

#include <bits/stdc++.h>
using namespace std;

    double  dis(double x1, double y1, double x2, double y2 )
    {

        double result,mm,m,nn,n,tm;
        mm=(x1-x2)*(x1-x2)*1.0;

        nn=(y1-y2)*(y1-y2)*1.0;

        tm=mm+nn;
        result=double(sqrt(tm));

        return result;

    }

    int main ()
    {
        double ans[6],x[2],y[2];
        for(int i=0;i<3;i++)
        {
            cin>>x[i]>>y[i];
        }

        double  ret=dis(x[0],y[0],x[1],y[1])+dis(x[0],y[0],x[2],y[2])+dis(x[1],y[1],x[2],y[2])
        ;
        printf("%.2lf",ret);
        return 0;
    }

by Plozia @ 2021-10-21 21:06:46

别用 x0,x1,y0,y1,x2,y2 之类的玩意

这个会跟 math 库中的东西冲突


by RevolutionBP @ 2021-10-21 21:12:06

好像是y1会和cmath库重复


by Madsome @ 2021-10-21 21:19:35

数组开太小了....................................................................................................................


by Madsome @ 2021-10-21 21:22:20

@yisongqingyu


|