From 892c6eedf1cc94d6a60e176414dfb0c80f1d9476 Mon Sep 17 00:00:00 2001 From: PIYUSH KHURANA <52041719+PIYUSH-01@users.noreply.github.com> Date: Sun, 20 Oct 2019 15:02:14 +0530 Subject: [PATCH] Update problem_4.cpp --- problem_4/problem_4.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/problem_4/problem_4.cpp b/problem_4/problem_4.cpp index 64edb8f..4e31bae 100644 --- a/problem_4/problem_4.cpp +++ b/problem_4/problem_4.cpp @@ -1 +1,20 @@ -//Wirte your code logic here! \ No newline at end of file +#include +#include + +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 = hh + 12; + if(strcmp(t12,"AM")==0 && hh==12) + hh = 0; + + printf("%02d:%02d:%02d",hh,mm,ss); + + return 0; + +} +