求大佬帮我看看哪里有问题,样例没问题但是一个测试也没过

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

wrp145 @ 2024-10-23 11:37:36

#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<math.h>
double len(double A[], double B[], double C[])
{
    double a = 0, b = 0, c = 0;
    a = sqrt(pow((B[0] - C[0]), 2) + pow((B[1] - C[1]), 2));
    b = sqrt(pow((A[0] - C[0]), 2) + pow((A[1] - C[1]), 2));
    c = sqrt(pow((B[0] - A[0]), 2) + pow((B[1] - A[1]), 2));
    double lent = a + b + c;
    return lent;
}
int main()
{
    double L = 0;
    double a[1];
    double b[1];
    double c[1];
    scanf("%lf %lf", &a[0],&a[1]);
    scanf("%lf %lf", &b[0],&b[1]);
    scanf("%lf %lf", &c[0],&c[1]);

    L = len(a, b, c);
    printf("%.2lf", L);
    return 0;
}

by tsgaoyunxuan @ 2024-11-25 20:25:13

你定义错了, int a[1]只有一个位置就是a[0] int a[1]里面a[1]不存在

double a[2],b[2],c[2];
cin>>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1];

|