What is exactly the output you get here?
I don't see any endlines. So if you want the table to display correctly you at least have to seperate the lines in your for loop.
like: cout << endl;
By the way:You can use the code blocks when you write a post by clicking the <> button next to the window you write in. Makes it more easy for all of us.