Poombom @ 2023-05-21 16:54:31
看不出来哪儿错了,麻烦众佬指出
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
double jl(double x1, double y1, double x2, double y2)
{
return sqrt(abs((x1 - x2) * (x1 - x2)) + abs((y1 - y2) * (y1 - y2)));
}
int main( )
{
double x1,x2,x3,y1,y2,y3;
double a,b,c,p,s;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
a=jl(x1,y1,x2,y2);
b=jl(x1,y1,x3,y3);
c=jl(x2,y2,x3,y3);
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("%.3lf",s);
return 0;
}
by Ningmo @ 2023-05-21 16:57:31
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("%.3lf",s);
改为
printf("%.2lf",a+b+c);
1、让你求得是周长不是面积 2、保留两位小数,三位小数是数据精度
by Poombom @ 2023-05-21 17:08:07
@Ningmo 感谢 。