#include <stdio.h> #include <limits.h> #define MAX_CHAR 1000 char buffer [MAX_CHAR+1]; char solution [MAX_CHAR+1]; int main(int argc, char ** argv) { FILE * in; int max, min; int diff, mindiff = INT_MAX; int i; /**Grenzen weather: 7 13 * soccer: 44 51*/ int val [2]; if (argc != 4) exit (1); for (i=0; i< 2; i++) val[i] = atoi(argv[i+2]); in = fopen (argv[1],"r"); if (in == NULL) exit (1); while (fgets(buffer, MAX_CHAR, in) != NULL) { max = atoi(&buffer[val[0]-1]); min = atoi(&buffer[val[1]-1]); diff = abs(max-min); if (diff < mindiff && diff != 0) { mindiff = diff; strcpy (solution, buffer); } } printf ("%s\n", solution); }