黄色CE求救。

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

bohemiao @ 2023-07-16 11:02:26

代码:

#include<bits/stdc++.h>
using namespace std;
double x1,x2,x3,y1,y2,y3,h;
double mm(double a){
    return a*a;
}
double cat(double a1,double b1,double a2,double b2){
    double n;
    n=sqrt(mm(a2-a1)+mm(b2-b1));
    return n;
}
int main(){
    scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
    h+=cat(x1,y1,x2,y2);
    h+=cat(x1,y1,x3,y3);
    h+=cat(x2,y2,x3,y3);
    printf("%.2lf",h);
    return 0;
} 

c⌒っ゚Д゚)っ求救


by lovely_fcukh @ 2023-07-16 11:04:51

y1是个函数,不能做变量名


by bohemiao @ 2023-07-16 11:41:13

@lovely_fcukh

#include<bits/stdc++.h>
using namespace std;
double x1,x2,x3,y_1,y2,y3,h;
double mm(double a){
    return a*a;
}
double cat(double a1,double b1,double a2,double b2){
    double n;
    n=sqrt(mm(a2-a1)+mm(b2-b1));
    return n;
}
int main(){
    scanf("%lf%lf%lf%lf%lf%lf",&x1,&y_1,&x2,&y2,&x3,&y3);
    h+=cat(x1,y_1,x2,y2);
    h+=cat(x1,y_1,x3,y3);
    h+=cat(x2,y2,x3,y3);
    printf("%.2lf",h);
    return 0;
} 

CE


by lovely_fcukh @ 2023-07-16 11:43:55

你都没提交,我提交了你的代码都A了(我真的不想A红题)


by bohemiao @ 2023-07-16 11:51:45

@lovely_fcukh 谢谢


|