Tuesday 15 September 2015

c - A bug in this code i can't resolve. Run time SIGSEGV -


I was trying this problem on the codechef, as far as I checked, the output is coming up properly .

>

P>
  contains # lt; Stdio.h & gt; # Include & lt; Math.h> Int main () {int m = 0; Long int i = 0, j = 0, c = 0, t = 0, v = 0, a = 0; Long int n = 0, q = 0, x [10] = {0}, y [10] = {0}, s [10] = {0}, f [10] = {0}; Long interval p [10] [10] = {0}, cl [10] = {0}; / * AREEN - X and Y, for the beginning and end of S and F tour P for instructions, 2C D for 2-D array for the storage of minimum seals. // printf ("Enter the number of test cases"); Scanf ("% d", & amp; t); For (M = 0; m & lt; m; ++) // Examination cases {// printf ("Enter the number of cells \ n"); Scanf ("% ld", & amp; n); Number of cells for // (i = 0; i & lt; n; i ++) // co-ordinates scanf ("% ld% ld", & amp; x [i], & amp; i [i ]); // printf ("Enter the number of trips q \ n"); Scanf ("% ld", & amp; Q); // someone. // Trips Scan ("% ld% ld", & amp; i [i], & amp; F [i]) of trips for I (i = 0; i & lt; q; i ++); (I = 0; i & lt; n) for the calculation of the difference between the coordinates for J (j = i; j & lt; n-1; j ++) p [i] [j] = abs (x) -1; i ++) [i] -x [j + 1]) + stomach (y [i] -y [j + 1]); / * For (i = 0; i & lt; n-1; i ++) {for (j = 0; j & lt; n-1; j ++) printf ("% d \ t", p [I] [j]); Printf ("\ n"); }} For loops of loop bar for / (v = 0; v & lt; q; v ++) // numbers {a = 0; (I = s [v] -1; i  f [v] -1, i ++) {cl [a] = p [ii] [ii]; [J = I; J & LT; F [V] -1, J ++) {if (P [I] [J]  [CL] [A]) CL [A] = P [I] J]; } A ++; } (* I = 0; i & lt; a; i ++) printf ("% d \ n", cl [i]); * / C = cl [0]; For (i = 0; i & lt; a; i ++) {if (cl [i]> c) c = cl [i]; Cl [i] = 0; } Printf ("% ld \ n", c); }} Return 0; }  


No comments:

Post a Comment