You will not find the answer in Google, because this is a simple logic issue. Look at your requirements:
- If the row number (starting from 0) is even then print
-
characters for odd numbers, but print even numbers correctly. - If the row number is odd, print
-
characters for even numbers, but print odd numbers correctly.