Time Conversion


#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
    char* time = (char *)malloc(11 * sizeof(char));
    scanf("%s",time);
    int len=strlen(time);
    if(*(time+len-2)=='A'){
        if(*(time+0)=='1' && *(time+1)=='2'){
            *(time+0)='0';
            *(time+1)='0';
            *(time+len-2)='\0';
            printf("%s",time);
        }
        else{
            *(time+len-2)='\0';
            printf("%s",time);
        }
       
    }
    else{
        if(*(time+0)=='1' && *(time+1)=='2'){
            *(time+len-2)='\0';
            printf("%s",time);
        }
        else{
            *(time+0)=1+*(time+0);
            *(time+1)=2+*(time+1);
            *(time+len-2)='\0';
            printf("%s",time);
        }
    }
    return 0;
}

Comments

Popular Posts