样例过但是0分

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

liuweida0330 @ 2024-03-06 13:23:45

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

by coderJerry @ 2024-03-06 13:52:50

@liuweida0330 请看题!dis 的返回值应为

return sqrt(abs((x1 - x2) * (x1 - x2)) + abs((y1 - y2) * (y1 - y2)));

|