C语言全红求助

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

CRAZYEGG @ 2021-09-06 10:21:18

#include <stdio.h>
#include <math.h>
double pu(double x1,double y1,double x2,double y2);
double x[5],y[5];
int main ()
{
    int i=0,C=0;
    for (i=1;i<=3;i++)
        scanf("%lf %lf",&x[i],&y[i]);
    C=pu(x[1],y[1],x[2],y[2])+pu(x[1],y[1],x[3],y[3])+pu(x[3],y[3],x[2],y[2]);
    printf("%.2lf",C);
    return 0;

}

double pu(double x1,double y1,double x2,double y2)
{
    double k=0;

    k=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

    return k;
}

by CRAZYEGG @ 2021-09-06 10:23:05

测试点全红,不知道哪里出了问题,请求大佬帮助。


by _SeeleVollerei_ @ 2021-09-06 11:23:32

@CRAZYEGG C要用double定义


|