G13460488251 @ 2022-09-29 19:41:10
# include <stdio.h>
# include <math.h>
int main(void)
{
int i;
float x1,x2,x3,sum;
int a[3];
int b[3];
for (i = 0;i < 3;++i)
{
scanf("%d %d",&a[i],&b[i]);
}
x1 = sqrt((a[0]-a[1])*(a[0]-a[1])+(b[0]-b[1])*(b[0]-b[1]));
x2 = sqrt((a[0]-a[2])*(a[0]-a[2])+(b[0]-b[2])*(b[0]-b[2]));
x3 = sqrt((a[1]-a[2])*(a[1]-a[2])+(b[1]-b[2])*(b[1]-b[2]));
sum = x1 + x2 + x3;
printf("%.2f\n",sum);
return 0;
}
by Ctrl_Z @ 2022-09-29 19:42:38
@G13460488251 您可以下载数据
by wf715 @ 2022-09-29 19:49:07
输入的坐标是实数,不一定是整数
by Wy_x @ 2022-09-29 19:55:15
float a[3]; float b[3];
scanf("%f %f",&a[i],&b[i]);
by Wy_x @ 2022-09-29 19:57:05
更改后 AC code
# include <stdio.h>
# include <math.h>
int main(void)
{
int i;
float x1,x2,x3,sum;
float a[3];//改正后
float b[3];//改正后
for (i = 0;i < 3;++i)
{
scanf("%f %f",&a[i],&b[i]);
//改正后
}
x1 = sqrt((a[0]-a[1])*(a[0]-a[1])+(b[0]-b[1])*(b[0]-b[1]));
x2 = sqrt((a[0]-a[2])*(a[0]-a[2])+(b[0]-b[2])*(b[0]-b[2]));
x3 = sqrt((a[1]-a[2])*(a[1]-a[2])+(b[1]-b[2])*(b[1]-b[2]));
sum = x1 + x2 + x3;
printf("%.2f\n",sum);
return 0;
}
by Wy_x @ 2022-09-29 19:57:32
@G13460488251
by G13460488251 @ 2022-10-02 18:36:49
谢谢大佬