#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

struct Point
{
    long x, y;
};

double areaPoly(Point poly[], int numVertices)
{
    int i, j;
    int b1, b2, h;
    double areaAccum;

    // Initialize the area accumulator
    areaAccum = 0.0;

    for (i = 0; i < numVertices; i++)
    {
        // Figure out the index of the next vertex
        j = (i+1) % numVertices;

        // Form a trapezoid with the next pair of coordinates and the
        // X axis
        b1 = poly[i].y;
        b2 = poly[j].y;
        h = poly[j].x - poly[i].x;

        // Add the area of this trapezoid to the total area
        areaAccum += 0.5 * (double)(h * (b1 + b2));
    }

    return areaAccum;
}


int main(void)
{
    FILE *fp, *fpOut;
    char line[10000], *nl;
    int numVertices;
    Point poly[2000];
    int i;
    double area;

    // Open the input and output files
    fp = fopen("poly.dat", "r");
    fpOut = fopen("poly.out", "w");

    // Get the first line of input
    fgets(line, sizeof(line), fp);
    nl = strchr(line, '\n');
    if (nl != NULL)
        *nl = 0;
    
    // Get the number of vertices in this polygon
    numVertices = atoi(strtok(line, " "));

    // Process lines until the number of vertices is not zero
    while (numVertices > 0)
    {
        // Read in the vertices of this polygon
        for (i = 0; i < numVertices; i++)
        {
            poly[i].x = atoi(strtok(NULL, " "));
            poly[i].y = atoi(strtok(NULL, " "));
        }

        // Print out the area
        fprintf(fpOut, "%0.2lf\n", areaPoly(poly, numVertices));

        // Get the next line of input
        fgets(line, sizeof(line), fp);
        nl = strchr(line, '\n');
        if (nl != NULL)
            *nl = 0;

        // Get the number of vertices in this polygon
        numVertices = atoi(strtok(line, " "));
    }

    // Close the files
    fclose(fp);
    fclose(fpOut);

    return 0;
}
