Without giving away too much, you need the two loops, one for the rows and one for the columns. You need to figure out how to organise the loops so for each row you put in the correct number of columns. Try to think of it in terms of what actions you need to carry at at each step of the way - it should become apparent.
if you're wondering why I didn't just give you code, well, this sounds like an progamming homework/assignment stuff and you need to be able to figure how to create algorithms yourself or you'll never be good at this.
Having said that, if you show us a pretty good attempt that isn't quite right, I'm sure someone would help you finish it off.