跪求大佬帮忙康康,80分的代码,最后一个测试点错了。

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

XZIT20200510102 @ 2020-11-14 19:24:34

#include <stdio.h>
#include <math.h>
double dis(int x1,int x2,int y1,int y2){
    double c;
    c=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    return c;
}
int main()
{
    int x1,x2,x3,y1,y2,y3;
    scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
    double c;
    c=dis(x1,x2,y1,y2)+dis(x1,x3,y1,y3)+dis(x2,x3,y2,y3);
    printf("%.2f",c);
    return 0;
}

C


by snowstorm1939 @ 2020-11-14 19:39:40

x1y1什么的改成double型


by AToj123 @ 2020-11-14 19:41:46

坐标值是实数

by kuncheng @ 2020-11-14 19:45:48

开float


|