Friday, October 21, 2011

[UVa] 11650 - Mirror Clock

Nice and fun! The only tricky case probably is a time that generated 0 hours, just make it 12 but keep the minute same. I don't know if handling for 24 hours time is needed but added that too.
#include <stdio.h>

int main()
{
    int tst, h, m, time;
    scanf("%d",&tst);
    while (tst--)
    {
        scanf("%d:%d",&h,&m);
        time = h*60 + m;
        if (time>720) time-=720;
        time = 720-time;

        h = (time/60);
        m = time%60;

        if (!h) h = 12;

        if (h<10)
            printf("0%d:",h);
        else
            printf("%d:",h);
        if (m<10)
            printf("0%d\n",m);
        else
            printf("%d\n",m);
    }
    return 0;
}

No comments:

Post a Comment

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...