As this looks like a home assignment, no code, just general directions. An exercise can only be useful for you if you do it by yourself.
You use the
immediate constant 10 four times. This is unsupportable. If you cannot or don't get a value from some data (user input, configuration file, resource, etc.), you should declare it as a constant
const uint maximumLineLength = 10;
You have only 3 difference patterns, not 5: #1, #2 and #5. It is apparent that two of then needs only two, nested, loops, and outer loop in #5 could be repeated twice in different direction, but I would advise you to think about the solution where you use the outer loop from 1 to 20 (
2 * maximumLineLength
), but only one.
If you don't understand why something doesn't work as planned, use the debugger. You should develop the basic skills of fixing code by yourself.
—SA