Start at a square. Move diagonally by incrementing or decrementing the needed variables one at a time to check for a match. If you don't find a match, stop counting. Repeat until done. There's nothing to show (aside from writing the whole thing for you).

Seriously, work it out on paper how you'd check for a win yourself in a linear method.

Quzah.