#C8169. Adding Minutes in a 24-Hour Clock
Adding Minutes in a 24-Hour Clock
Adding Minutes in a 24-Hour Clock
You are given a time in \(HH:MM\) format (24-hour clock) and an integer representing a number of minutes to add. Your task is to compute the new time after adding the given minutes. The time must wrap around if it goes past midnight.
For example, adding 200 minutes to 09:15
yields 12:35
, and adding 30 minutes to 23:45
yields 00:15
due to the wrap-around at midnight.
Note: The input time is always given in a valid \(HH:MM\) format, and the output should also be in the same \(HH:MM\) format, with hours and minutes padded to two digits if necessary.
inputFormat
The input is provided via standard input (stdin) as a single line containing:
- A time string in the format
HH:MM
(24-hour clock). - An integer, representing the number of minutes to add.
The two values are separated by a space.
outputFormat
Output the new time in the \(HH:MM\) format (24-hour clock) via standard output (stdout). Ensure that both hours and minutes are displayed as two digits (i.e., padded with a leading zero if needed).
## sample09:15 200
12:35
</p>