Input
The input data contains multiple test instances, one row per test instance, and the beginning of each line is an integer n (3<=n<=100), which represents the number of sides of the polygon (and, of course, the number of vertices), followed by the coordinates of the n vertices given in a counterclockwise order (x1, y1, x2, y2 ... xn, Yn), in order to simplify the problem, all coordinates here are represented by integers.
All integers in the input data are within a 32-bit integer range, and n=0 represents the end of the data and does not handle it.
Output
For each test instance, output the corresponding polygon area, and the result is exactly one decimal point after the decimal.
The output for each instance takes up one row.
Sample Input
3 0 0 1 0 0 14 1 0 0 1-1 0 0-10
Sample Output
0.52.0
/*
The triangular three-vertex coordinates are a (a, b), C,d, C (e,f), then the area of the triangle is
s=1/2* third-order determinant,
The third-order determinant is:
A B 1
C D 1
E F 1
A*d+b*e+c*f-d*e-b*c-a*f
*/
#include <stdio.h>DoubleAreaDoubleADoubleBDoubleCDoubleDDoubleEDoublef);voidMain () {intN; Doublex[ -],y[ -]; while(SCANF ("%d", &n) = =1&& n>=3&& n<= -) { inti; Doublesum=0; for(i=0; i<n;i++) {scanf ("%LF%LF", x+i,y+i); if(i>=2) Sum+=area (x[0],y[0],x[i-1],y[i-1],x[i],y[i]); } printf ("%.1lf\n", sum/2); }}DoubleAreaDoubleADoubleBDoubleCDoubleDDoubleEDoublef) { returna*d+b*e+c*f-d*e-b*c-a*F;}
n vertices make up the area of a polygon