前后两者有什么区别吗,为什么一个ac,一个全wa

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

wcwrcxx @ 2024-12-10 20:55:28

#include<stdio.h>
#include<math.h>
double length(double x,double y,double x1,double y1);
int main(void){
    double a[3],b[3];
    double sum=0.0;
    for( int i=0;i<3;i++){
        scanf("%ld %ld",&a[i],&b[i]);
    }
    sum=length(a[0],b[0],a[1],b[1])+length(a[1],b[1],a[2],b[2])+length(a[0],b[0],a[2],b[2]);
    printf("%.2lf",sum);
}
double length(double x,double y,double x1,double y1){
    double lth;
    lth=sqrt(abs(x1*x1-x*x)+abs(y1*y1-y*y));
    return lth;
}

#include<stdio.h>
#include<math.h>
double length(double x,double y,double x1,double y1);
int main(void){
    double a,b,c,d,e,f;
    double sum=0.0;
        scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f);
    sum=length(a,b,c,d)+length(a,b,e,f)+length(c,d,e,f);
    printf("%.2lf",sum);
}
double length(double x,double y,double x1,double y1){
    return sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
}

by 4041nofoundGeoge @ 2024-12-10 21:08:24

@wcwrcxx因为你第一个的 scanf 的里写的是 %ld


|