Since you have no endl; at the end of your cout statement I think it would print it out horizontally
to begin with. If not you could always just display 20 0s at once.
As far as I know there is no easy linux fix---ncurses or something and some programming effort are necessary here. Once u hit return you're on a new line...thats the thing about return isn't it?
This solution handles overflow correctly (though I just realized that after a line in the console has been filled, it reverts to printing zeroes vertically. Will have to add a check to see if a line has been filled, and if so, increment the line).