#include #include typedef struct { double x,y; } POINT; typedef struct { int len; POINT *vertices; } POLYGON; void readPoint(POINT *p) { scanf("%lf%lf",&(p->x),&(p->y)); } POLYGON *readPolygon() { int i,n; POLYGON *poly; scanf ("%d",&n); poly = (POLYGON *) malloc(sizeof (POLYGON)); poly->len = n; poly->vertices = (POINT *) malloc (n * sizeof(POINT)); for (i=0; ivertices[i])); } return poly; } /***************************************************************** * This is the function that you must modify. * It should return 1 if "testPoint" is inside "poly", * and 0 if otherwise. * The rest of the program should not be changed, for * compatibility with the test data. *****************************************************************/ int pointInPolygon(POLYGON *poly, POINT *testPoint) { /* * This is wrong. It always returns TRUE. */ return 1; } main (int argc, char *argv[]) { POINT *test; POLYGON *poly; test = (POINT *) malloc(sizeof(POINT)); readPoint(test); poly = readPolygon(); if (pointInPolygon(poly,test)) printf("in\n"); else printf("out\n"); }