Unless i am crazy, but the debug buid of my code in visual studio give the "right answer", however the release version gives the incorrect version. Any reason this for their strange behavior?
My guess is that you're doing something very wrong, such as writing out of array bounds. In debug version variables may not be held as compactly as in release and thus damage could be avoided. I'm sure there are more similar possible causes, though I can't think of any right now..
Either way, try posting your code here.
I find the most common reason for this is you are using variables which have not been initialized. Debug and Release both handle this situation differently (debug will typically fill them all with something so output is deterministic, whereas Release will just leave them uninitialized, giving you garbage RAM).
Make sure you are initializing all your variables.
hamsterman's idea of going outside an array bounds is also possible.
There's no way we can say for sure until we see code.