Problem Summary
Given a time in 12-hour AM/PM format, convert it to 24-hour time.
About the 12-hour clock:
https://en.wikipedia.org/wiki/12-hour_clock
Solution
Note that Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock, and similarly, noon is 12:00:00PM on a 12-hour clock and 12:00:00 on a 24-hour clock.
Once we know this, the coding is trivial.
Code
|
|