I am not understanding your question. If I clean up the code a little you might see how it was arrived at. It looks like we are doing matrix math of some form from the description.
First off there appear to be a few extra comma's, I don't know if that's your typo or part of the problem. Just remember that '0' is a number in C\C++ and you should be able to see it. As for how I would arrive at the answer personally I would have written it into an IDE and compiled it.