/* * @(#) polyarea.c - A free-shape polygon area calculator. * (c) 1997 Ivan Maidanski http://ivmai.chat.ru * Freeware program source. All rights reserved. ** * Language: ANSI C * Tested with: Watcom C 16/32 v10.0 * Last modified: 1997-11-13 11:40:00 GMT+03:00 */ /* Input data format: N x1 y1 ... xn yn */ #include #include #define MAXN 100 double x[MAXN],y[MAXN]; int input_polygon(double x[], double y[]) { int i,n; scanf("%d",&n); if (n>MAXN) return -1; for (i=0;i=1.0) return 0; if ((t=((x1-x3)*(y4-y3)-(x4-x3)*(y1-y3))/d)<=0.0 || t>=1.0) return 0; *x=(x2-x1)*t+x1; *y=(y2-y1)*t+y1; return 1; } void shift_list(double x[], int i, int n) { for (;i