Zkxxxv_h @ 2022-09-16 14:43:42
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
struct pair{
double x, y;
};
double len(pair a, pair b){
return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int main()
{
struct pair a, b, c;
scanf("%lf%lf", &a.x, &a.y);
scanf("%lf%lf", &b.x, &b.y);
scanf("%lf%lf", &c.x, &c.y);
printf("%.2lf", len(a, b) + len(a, c) + len(b, c));
return 0;
}
by Zkxxxv_h @ 2022-09-16 14:44:47
函数定义的变量不能是结构体类型吗
by SDLTF_凌亭风 @ 2022-09-16 14:52:06
主函数第三行,直接写pair a,b,c
by dmgjh @ 2022-09-16 15:09:22
@skkyk 结构体变量定义的时候不用加struct
by Zkxxxv_h @ 2022-09-16 15:21:17
你们说的不对,定义变量加不加struct都行。
by Zkxxxv_h @ 2022-09-16 15:21:43
就是在函数那一行出现问题
by _cyle_King @ 2022-09-16 15:25:01
函数里面加上 struct 就可以了。
by _cyle_King @ 2022-09-16 15:26:09
@_cyle_King 就是 pair 的声明前加上 struct。
by Mr学霸君 @ 2022-09-16 15:26:21
函数参数pair前要加struct,建议用C++(
by CH_mengxiang @ 2022-09-16 20:45:58
实测换C++14评测满分
by 孙轩宇 @ 2022-10-18 15:02:50
这个是C,应在前面加struct