求助各位大佬,样例过了但是才80分,第五个wa了

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

ECHO2020 @ 2021-12-09 17:32:42

帮忙看看

#include<bits/stdc++.h>
using namespace std;
double dis(float x1,float y1,float x2,float y2){
    float js=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    return js;
}
int main(){
    int x1,x2,x3,y1,y2,y3;
    cin>>x1>>y1;
    cin>>x2>>y2;
    cin>>x3>>y3;
    float ans=0,a,b,c;
    a=dis(x1,y1,x2,y2);
    b=dis(x1,y1,x3,y3);
    c=dis(x2,y2,x3,y3);
    ans+=a+b+c;
     printf("%.2f",ans);
    return 0;
}

by Zvelig1205 @ 2021-12-09 17:36:59

intfloat 都换成 double


by ECHO2020 @ 2021-12-09 17:42:45

@极冬寒雪 已过,感谢大佬!


by Zjxrhy @ 2022-02-19 20:14:11

@极冬寒雪 大佬帮我也看看好吗,全wa了,但我又觉得没啥错。。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double x1,x2,x3,y1,y2,y3;
    scanf("%lf %lf",&x1,&y1);
    scanf("%lf %lf",&x2,&y2);
    scanf("%lf %lf",&x3,&y3);
    double s1,s2,s3;
    s1=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    s2=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
    s3=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y2-y3));
    double ans=s1+s2+s3;
    printf("%.2lf",ans);
    return 0;
}

by Zvelig1205 @ 2022-02-20 12:31:09

@zhaojiayang666 12 行 y2->y1。


by Zjxrhy @ 2022-02-21 17:13:16

@极冬寒雪 哎呀我捣鼓错了,谢谢大佬!


|