有关三角形坐标面积代码

来源:互联网 发布:流畅的python pdf 编辑:程序博客网 时间:2024/06/06 02:06
#include <bits/stdc++.h>




int main()
{
    double x1,x2,x3,y1,y2,y3,a,b,c,s,q;
    while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF)
    {
       a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
       b=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
       c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
       q=(a+b+c)/2;
       s=sqrt(q*(q-a)*(q-b)*(q-c));
       printf("%.1f\n",s);
    }
    return 0;

}求三角形面积

0 0