Now, just need some assistance on this one which I am not sure how to put it this way in C programming under linux - anyone help?
Quote
You have a clock with 4 buttons, H+, H-, M+, M-. The two H buttons change hours without affecting the minutes, while the two M buttons change the minutes without affecting the hours.
H+ increases hours by 1. If hours was 23, pressing H+ sets hours to 00.
H- decreases hours by 1. If hours was 00, pressing H- sets hours to 23.
M+ increases minutes by 1. If minutes was 59, pressing M+ sets minutes to 00.
M- decreases minutes by 1, If minutes was 00, pressing M- sets minutes to 59.
Write a C prgram which will read two times and determine the smallest number of button presses to change the setting from the first time to second time.
There will be two lines of input, each containing a time, the hours followed by the minutes.
The output will be a single number.
Example:
Input: 1755
Output: 2
Limit: The hours will be in the range [0...23] and the minutes in the range [0...59]
H+ increases hours by 1. If hours was 23, pressing H+ sets hours to 00.
H- decreases hours by 1. If hours was 00, pressing H- sets hours to 23.
M+ increases minutes by 1. If minutes was 59, pressing M+ sets minutes to 00.
M- decreases minutes by 1, If minutes was 00, pressing M- sets minutes to 59.
Write a C prgram which will read two times and determine the smallest number of button presses to change the setting from the first time to second time.
There will be two lines of input, each containing a time, the hours followed by the minutes.
The output will be a single number.
Example:
Input: 1755
Output: 2
Limit: The hours will be in the range [0...23] and the minutes in the range [0...59]


Sign In
Create Account


Back to top









