C语言-没有明白为什么除了第一个点都错了

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

1oveAsuka @ 2021-10-28 01:19:16

后面的数据会相差零点几 不知道是哪一步发生了数据损失

#include<stdio.h>
#include<math.h>
double main()
{
    double q,w,e,x1,x2,x3,y1,y2,y3,u;
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y2,&x2,&y2,&x3,&y3);
    q=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    w=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    e=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    u=q+w+e;
    printf("%.2lf",u);
    return 0;
}

by 华年 @ 2021-10-28 08:39:46

应该是
scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);


by 1oveAsuka @ 2021-10-28 20:20:00

@华年 啊,感谢


|