TMECONV- Editorial

PROBLEM LINKS:

Practice

Contest

Author:

bigo_admin

Tester and Editorialist:

subhasis10

DIFFICULTY:

EASY

PREREQUISITES:

12 hr to 24 hr clock time conversion

PROBLEM:

Given a time in 12hr format print the same time in 24hr format.

EXPLANATION:

For a given time in 12hr format we check if it is in AM or PM.

If it is in PM and the hour is less and 12 then we add 12 to it, but if the hour is equal to 12 then we keep it as it is.

If it is in AM and the hour is equal to 12 then we make the hour as 0 and do nothing otherwise.

TESTER’S SOLUTION:

Can be found here

It’s amazing seeing how one mere thing can create many conflicts. Problem is certainly easy, and so is solution. But it took me more than half an hour to befit the requirements of Codechef for this problem. Learn new things in C today:

printf("%02d%c%02d%c%02d\n", hh, c1, mm, c2, ss);
1 Like
//