11576 - Time conversion
raw download clone
C
views 22
,
size 514 b
#include <stdio.h>

int main(void)
{
    char c;
    int i = 1, h, flag = 0;
    char o[5];

    while((c = getchar()) != '\n')
    {
        o[i] = c;
        i++;
    }
    h = 10 * (o[1] - '0') + (o[2] - '0');
    if(h >= 12)
    {
        flag = 1;
        h -= 12;
    }
    int key_info = 'a' * ((flag+1)%2) + 'p' * flag ;
    if(h < 10)
        printf("0%d:%c%c %c.m.", h, o[3], o[4], key_info);
    else
        printf("%d:%c%c %c.m.", h, o[3], o[4], key_info);

    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.