好难啊......

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

Nina__happy @ 2024-07-29 19:35:02

对于一个蒟蒻来说,连题都读不懂(好吧,确切的来说是冒得方法做啊喂)哪位大佬解释哈子巴


by Grace25 @ 2024-07-29 19:36:45

两两算一下加起来不就好了


by Nina__happy @ 2024-07-29 19:38:06

@Grace25 嗷嗷嗷,感谢大佬


by Grace25 @ 2024-07-29 19:40:53

@Nina__happy 不客气awa


by Nina__happy @ 2024-07-29 19:41:43

@Grace25 聪明如你


by Grace25 @ 2024-07-29 19:43:27

@Nina__happy 好家伙


by Nina__happy @ 2024-07-29 19:48:51

/```#include<bits/stdc++.h>

using namespace std;

bool jl(int a,int b,int c,int d){

int num=sqrt(abs((a-c)(a-c))+abs((b-d)(b-d))); return num; }

int main(){

int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e>>f;
int num=jl(a,b,c,d)+jl(a,b,e,f)+jl(c,d,e,f);
cout<<num;

} ```\ 0分求助


by chenxu11 @ 2024-07-29 20:05:28

直接代入公式就行了

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double f(double x1,double y1,double x2,double y2){
    double dis;
    dis= double (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    return dis;
}
int main(){
    double x[5],y[5];
    double s=0;
    for(int i=1;i<=3;i++)
        cin>>x[i]>>y[i];
    s+=f(x[1],y[1],x[2],y[2]);
    s+=f(x[1],y[1],x[3],y[3]);
    s+=f(x[3],y[3],x[2],y[2]);
    printf("%.2lf",s);
    return 0;
}

by Nina__happy @ 2024-07-29 20:06:46

@chenxu11 三克油


|