#include <iostream>
#include <list>
#include <cmath>
struct P { double x, y; };
class tri {
double sum;
public:
tri() { sum = 0.0; }
double result() { return 0.5 * fabs(sum); }
void operator()(P p1, P p2) { sum += p1.x * p2.y - p2.x * p1.y; }
};
void mytransform(std::list<P>::const_iterator s, std::list<P>::const_iterator e, tri &S) {
std::list<P>::const_iterator p, q;
if ((p = s) == e) return;
if ((q = ++s) == e) return;
while (q != e) {
S(*p, *q);
p++; q++;
}
}
int main() {
tri s;
static P table[] = { {6.0, 6.0}, {5.0, 6.0}, {4.0, 4.0}, {5.0, 4.0}};
std::list<P> points;
for (unsigned int i = 0; i < sizeof(table) / sizeof(P); i++)
points.push_back(table[i]);
points.push_back(table[0]);
mytransform(points.begin(), points.end(), s);
std::cout << s.result() << std::endl;
return 0;
}
/* end */