/* A very basic poly_area in C. Illustrates arrays, loops, functions and minimal pointers. Does not use structures and types or memory allocation yet. */ #include #include #include int NMAX=1000; /* Function prototypes */ int read_nodes( double [2][NMAX], int ); void get_tri(int, double [2][2], double [2][NMAX], int); double calc_da(double [2][2]); void check_dir(int, int *, double); int main(int argc, char *argv[]){ /* Declare main variables */ /* nodes_xy -- array to hold points, NMAX maximum number. */ /* n_nodes -- number of nodes entered. */ /* tri_vec -- array for a single triangle. */ /* area, darea -- accumulated area and area of each addtional */ /* increment. */ double nodes_xy[2][NMAX]; int n_nodes; double tri_vec[2][2]; double area, darea; int sign_da; /* Start message */ printf("=== Computing polygon area ==\n"); /* Get node list */ n_nodes=read_nodes(nodes_xy, NMAX); /* Check we have enough nodes */ if ( n_nodes < 3 ) { printf("ERROR: Not enough nodes entered\n"); exit(-1); } for (int i=2;i