//海伦公式 s=sqrt(p*(p-a)*(p-b)*(p-c)) 其中p为半周长
#include<iostream>
#include<math.h>
#include<iomanip>
#include<stdlib.h>
using namespace std;
double len1(double x0,double y0,double x,double y)
{
return sqrt(abs(x0-x)*abs(x0-x)+abs(y0-y)*abs(y0-y));
}
int main()
{
double x1,y1,x2,y2,x3,y3;
double p,l1,l2,l3,s;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3)
{
if((x1==0)&&(x2==0)&&(x3==0)&&(y1==0)&&(y2==0)&&(y3==0))
break;
l1=len1(x1,y1,x2,y2);
l2=len1(x1,y1,x3,y3);
l3=len1(x2,y2,x3,y3);
p=(l1+l2+l3)/2;
s=sqrt(p*(p-l1)*(p-l2)*(p-l3));
cout<<setiosflags(ios::fixed)<<setprecision(1)<<s<<endl;
}
return 0;
}
11-17
07-14
07-14
07-13
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交