文章
166
粉丝
68
获赞
825
访问
49.7k
#include <bits/stdc++.h>
using namespace std;
struct triEdge{
int x1,y1;
int x2,y2;
double length;
triEdge():x1(0),y1(0),x2(0),y2(0),length(0){}
triEdge(int x1,int y1,int x2,int y2){
this->x1 = x1;
this->y1 = y1;
this->x2 = x2;
this->y2 = y2;
this->length = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
};
int main(){
int a,b,c,d,e,f;
while(cin>>a>>b>>c>>d>>e>>f){
triEdge te1 = triEdge(a,b,c,d);
triEdge te2 = triEdge(a,b,e,f);
triEdge te3 = triEdge(c,d,e,f);
double p = (te1.length + te2.length + te3.length) / 2;
double s = sqrt(p * (p - te1.length) * (p - te2.length) * (p - te3.length));
printf("%.2lf\n", s);
}
}
登录后发布评论
精确度问题,计算边长时用的是int,而开根号有可能出现小数,有可能会导致精确度缺失