/* correct.c -- compute the corrected distance */ #include #include "ios.h" /* using the input/output service module */ #define ERR_LINE 1 #define ERR_SIZE 2 #define ERR_NO_UNPERTURBED 3 #define ERR_MANY_UNPERTURBED 4 #define ERR_ACURACY 5 static float Omega [124]; void main ( int argc, char * argv [] ) { int x,y,z, k, v, m,flag; char * from; float tot, tot000; FILE * outfile; if ( argc < 3 ) err_command_line ( "correct infile outfile" ); open_input_file ( argv [1] ); get_line_sure ( & from ); /* skip the first line */ m = 0; flag = 0; while ( 0 <= get_line ( & from ) ) { if ( 4 != sscanf ( from, "%d %d %d %e", &x, &y, &z, &tot ) ) { printf ( "wrong input line [%s]\n", from ); exit ( ERR_LINE ); } if ( x==0 && y==0 && z==0 ) { tot000 = tot; ++flag; } else if ( m < 124 ) Omega [m++] = tot; else { printf ( "more than 124 perturbed cases\n" ); exit ( ERR_SIZE ); } } if ( flag < 1 ) { printf ( "no unperturbed case\n" ); exit ( ERR_NO_UNPERTURBED ); } if ( flag > 1 ) { printf ( "%d > 1 unperturbed cases\n", flag ); exit ( ERR_MANY_UNPERTURBED ); } v = 1; for ( k=0; k= tot000 ) ++ v; ++ m; outfile = open_output_file ( argv [2] ); fprintf ( outfile, "[ %d / %d ]\n", v, m ); if ( m >= 10 ) exit (0); printf ( "insufficient accuracy: %d < 10 cases\n", m ); exit ( ERR_ACURACY ); } /* end of correct.c */