这就是按照公式写的,为什么错!??大佬求调!

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

Weizhuo_Zhao @ 2023-08-16 22:10:51

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

by LAICZ @ 2023-08-16 22:13:53

@Weizhuo_Zhao 稍等看一下


by XuYueming @ 2023-08-16 22:14:59

输入炸了

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

by XuYueming @ 2023-08-16 22:15:22

@Weizhuo_Zhao 多了个%


by rnf5114 @ 2023-08-16 22:15:29

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

@Weizhuo_Zhao


by LAICZ @ 2023-08-16 22:16:10

离谱,这输入就很无语


by Weizhuo_Zhao @ 2023-08-16 22:17:22

@rnfmabj5114 @XuYueming 谢谢!


|