It is very trivial, so I'll leave the code to you.
First, the first two for loops should be swapped:
for (j=0;j<4;j++) {
for (i=0;i<3;i++) {
for (k=0;k<5;k++) {
}
}
}
Then it's just a case of getting your space, tab and linefeed at the right point.
It will always be easier if you learn to get the data in the right order first, then worry about what you are going to do with it.