#include <stdio.h>
#include <math.h>
typedef struct point_t {
double x, y;
};
double DIST(const struct point_t * a, const struct point_t * b);
double AREA(double a, double b, double c);
int main() {
struct point_t p, q, r;
double d1, d2, d3, area;
printf("Please enter the coordinates of the triangle vertices and press ENTER.\n");
scanf("%lf %lf %lf %lf %lf %lf", &p.x, &p.y, &q.x, &q.y, &r.x, &r.y);
d1 = DIST(&p, &q);
d2 = DIST(&p, &r);
d3 = DIST(&q, &r);
area = AREA(d1, d2, d3);
area = AREA(d1, d2, d3);
printf("The area of the triangle is %lf\n", area);
return(0);
}
inline double sqr(double x) {
return(x * x);
}
double DIST(const struct point_t * a, const struct point_t * b) {
return(sqrt(sqr(a->x - b->x) + sqr(a->y - b->y)));
}
double AREA(double a, double b, double c) {
double p = 0.5 * (a + b + c);
double ar = sqrt(p * (p - a) * (p - b) * (p - c));
return(ar);
}