Untitled
raw download clone
C
views 31
,
size 715 b
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    
    if(a==1&&b>=2){                   //1200~1959
    printf("%d%d:%d%d",a-1,b-2,c,d);
    printf(" ");
    printf("p.m.");
    }
    else if(a==2&&b>=2){             //2200~2359
        printf("%d%d:%d%d",a-1,b-2,c,d);
        printf(" ");
        printf("p.m.");
    } 
    else if(a==2&&b<2){             //2000~2159
        printf("%d%d:%d%d",a-2,b+8,c,d);
        printf(" ");
        printf("p.m.");
    }
    else{                           //0000~1159
        printf("%d%d:%d%d",a,b,c,d);
        printf(" ");
        printf("a.m.");
    }
        return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.