Formatting seconds as hours:minutes:seconds
Bug
Handling a case of 0 minutes is a bit more involved. For example, giving 3601 as an input produces 1:1 instead of expected 1:00:01.

Trust your math
min and sec are guaranteed to be less than 60. There is no point to test for it.

Computing spaces
I recommend not to compute them explicitly. You know that the output should be right-aligned into the 7-character-wide field. An std::setw(7)  manipulator is specifically designed to do the job. Write your output to the string (or a stringstream), and
      std::cout &lt;&lt; std::setw(7) &lt;&lt; s &lt;&lt; '\n';

will achieve the goal.