Skip to content

Instantly share code, notes, and snippets.

@esthicodes
Created August 24, 2021 00:54
Show Gist options
  • Save esthicodes/aa367111ab7e33c4bf24286dc30ff93c to your computer and use it in GitHub Desktop.
Save esthicodes/aa367111ab7e33c4bf24286dc30ff93c to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include<string.h>
#include<stdio.h>
int main() {
int hh, mm, ss;
char t12[3];
scanf("%d:%d:%d%s", &hh, &mm, &ss, t12);
if(strcmp(t12, "PM")==0 && hh != 12) hh +=12;
if (strcmp(t12, "AM")==0 && hh==12) hh = 0;
printf("%02d:%02d:%02d", hh, mm, ss);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment