The following (quite simple) source works just fine for me under Win32 compiled with Dev-Cpp.
But when I want to submit it, the result is always SIGSEGV!
Could anyone help me why is that? I tried to read the lines in a simple array, a stringarray etc, but the result is always SIGSEGV...
Thanks before
[c]
#include <stdio.h>
#include <stdlib.h>
struct valuepair{
int value1;
int value2;
}VALUEARRAY[200];
int calculate_steps(int num1, int num2){
int diff, steps = 0, paratlan = 0;
if(num1 == num2)
return 0;
if((num1+1) == num2)
return 1;
diff = (num2 - 1) - (num1 + 1);
if(diff%2)
paratlan = 1;
steps = (diff/2)+2+paratlan;
return steps;
}
int main(void){
int i, j, numofrows, inputted = 0, outputted;
for(scanf("%d", &numofrows);inputted<numofrows;++inputted){
scanf("%d %d", &i, &j);
VALUEARRAY[inputted].value1 = i;
VALUEARRAY[inputted].value2 = j;
}
for(outputted=0;outputted<numofrows;++outputted)
printf("%d\n", calculate_steps(VALUEARRAY[outputted].value1, VALUEARRAY[outputted].value2));
return 0;
}
[/c]