solution.cpp 501 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef pair<double, double> PDD;
#define x first
#define y second

double cross(double x1, double y1, double x2, double y2)
{
    return x1 * y2 - x2 * y1;
}
int main()
{
    PDD pts[3];
    for (int i = 0; i < 3; i++)
    {
        scanf("%lf%lf", &pts[i].first, &pts[i].second);
    }
    cout << 0.5 * cross(pts[1].x - pts[0].x, pts[1].y - pts[0].y, pts[2].x - pts[0].x, pts[2].y - pts[0].y) << endl;
    return 0;
}