I am getting a runtime error(Runtime Error(SIGSEGV))for this code(given below).
It is running fine in the site’s compiler but it shows error when I submit the code as an answer.
The question is http://www.codechef.com/problems/DDISH/
It would be a great help if someone could guide me on this.
but I am reading the value of t and then using it in the loop.
If it was a problem , it didn’t give me any error when I compiled using the sites compiler .
It just showed an error after I submitted it. I appreciate your help and I will definitely try it. Thank You.
For this particular program, you are initializing all the array elements to 0 ONLY ONCE. In this case, the following bit of info will help you:
All global variables/arrays are automatically initialized to 0.
So, your array is initialized to 0 automatically. Need not worry about that.
If you, however, need to re-initialize them repeatedly in a loop (for some other problem, maybe), then you would need to do that in a loop (as your program currently does.)
NZEC stands for Non-Zero Exit Code. You must have already noticed a “return 0” at the end of many programs. That particular return value means, the program finished execution without any problems, and that it can now exit successfully. (Any other return value will be interpreted as some error that occurred during runtime.)
There are many reasons for getting runtime errors. Not having an explicit ‘return 0’ is one reason. Calling some library method with illegal arguments, which might in turn, call exit(xx); upon sensing illegal arguments, where xx in a non-zero value, is another.