#include <stdio.h> unsigned foo( unsigned t ) { unsigned minute = (t/100*60 + t%100 + 110)%1440; return minute/60*100 + minute%60; } int main( void ) { printf( "%04u\n", foo(1120) ); printf( "%04u\n", foo(2230) ); printf( "%04u\n", foo(2320) ); }