计算三角形面积(叉积)

2019-04-14 12:00发布

#include
#include
#include
using namespace std;
typedef struct point{
   double x;
   double y;
}point;
double CrossProduct(point A, point B, point C){
   return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);
}
int main()
{
   point a, b, c;
   double temp, area;
   cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
   temp = CrossProduct(a, b, c);
   area = 0.5*fabs(temp);
   cout << area << endl;
   return 0;
}