Formatting seconds as hours:minutes:seconds This is basically my school homework and I want to know what to improve, and what not to do.
The homework basically is this:
You will get a input in seconds, which is supposed to be shown as H:MM:SS where H is hours M is minutes and S is seconds. The formatting is supposed to look like in my example. ( note: In output, 0s from the left will be ignored and replaced with spaces )

Input:
3000
730
308
3967
15
1

Output:
The count of entires: 6
  50:00
  12:10
   5:08
1:06:07
     15
      1


So basically, I did a code based on the example. I haven't got more informations, just that but it is enough and fun.
Here goes my code:

#include &lt;iostream&gt;
#include &lt;fstream&gt;

inline int CountSpaces ( int hod, int min, int sec ){
    int spaces = -1;
    // 1:06:07
    if ( hod )
        return 0;
    if ( min &gt;= 10 )
        return 2;
    if ( min &lt; 10 &amp;&amp; min &gt; 0 )
        return 3;
    if ( sec &gt;= 10 )
        return 5;
    if ( sec &lt; 10 )
        return 6;
    // in the case something goes wrong..
    return spaces;
}

// convert time to hour,min,seconds
void CalcTime ( int value, int&amp; hour, int&amp; min, int&amp; sec ){
    hour = value / 3600;
    min = value % 3600 / 60;
    sec = value % 60;
}

// output spaces 
void Space ( int* hour, int* min, int* sec ){
    int spaces = CountSpaces ( *hour , *min , *sec );
    if ( !spaces ) return;
    for ( int i = 0 ; i &lt; spaces ; i++ ){
        std::cout &lt;&lt; ' ';
    }
}

void Write ( int time ){
    if ( time &lt;= 0 )
        return;

    int hour;
    int min;
    int sec;

    CalcTime ( time , hour , min , sec );
    Space ( &amp;hour , &amp;min , &amp;sec );

    bool bHour = false;
    bool bMin = false;
    if ( hour &gt; 0 ){
        bHour = true;
        std::cout &lt;&lt; hour &lt;&lt; ':';
    }
    if ( min &lt; 60 &amp;&amp; min &gt; 0 ){
        bMin = true;
        if ( bHour ){
            if ( min &lt; 10 ){
                std::cout &lt;&lt; '0';

            }
        }
        if ( min &gt; 0 )
            std::cout &lt;&lt; min &lt;&lt; ':';

    }
    if ( sec &lt; 60 &amp;&amp; sec &gt;= 0 ){
        if ( sec &lt; 10 &amp;&amp; bMin ){
            std::cout &lt;&lt; '0';
        }
        std::cout &lt;&lt; sec &lt;&lt; std::endl;
    }
}


int main ( ){
    std::ifstream fin ( "in.txt" );

    if ( !fin ) return 1;

    int num;
    int count = 0;
    int arr[100];
    while ( fin &gt;&gt; num ){
        arr [ count++ ] = num;
    }
    std::cout &lt;&lt; "The count of entires: " &lt;&lt; count &lt;&lt; std::endl;
    for ( int i = 0 ; i &lt; count ; i++ ){

        Write ( arr [ i ] );
    }

    return 0;
}
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.