Hello again - I know I have returned once again, been busy with uni stuff lately.
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?
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]
We don't write your homework for you, but we'll gladly help you. Why don't you write down the steps you would take to do it manually, and then work from there? Post what you've got once you're done with the manual part so I can point you in the right direction.
sudo rm -rf /
Thats OK, I will get the code attempt tomorrow night, and see what happens from there..
it is pretty late down here right now (Im in Australia)
Code:While( !User.hasAnswer ) { User.askQuestion(); if( User.postCode && User.putForthEffort ) { CodeCallMembers.Help(); User.hasAnswer = true; } else { CodeCallMembers.Laugh(); } }
-CDG10620
Software Developer
Just because I'm an insufferable ****, I would amend your if clause to:
Code:if( User.question.type == Question::Homework ) { <original if clause here> } else if( User.question.type == Question::ExpandKnowledge ) CodeCallMembers.Help(); else CodeCallModerator.delete(User.question);
sudo rm -rf /
That's a good point. I won't argue with that. I just felt that the Question::Fun would not apply to someone who is obviously lazy and wants us to do homework for them. Typically they post the question, WingedPanther or someone else says "Wow this looks like homework" and then the person admits is a homework assignment or a project.![]()
-CDG10620
Software Developer
I understand what you're saying. Maybe we'll have to add that in.
Code:While( !User.hasAnswer ) { User.askQuestion(); if( User.question.type == Question::Homework ) { if( User.postCode && User.putForthEffort ) { CodeCallMembers.Help(); User.hasAnswer = true; } else { CodeCallMembers.Laugh(); } } else if( User.question.type == Question::ExpandKnowledge ) CodeCallMembers.Help(); else CodeCallModerator.delete(User.question); }
Last edited by cdg10620; 03-25-2010 at 11:50 AM. Reason: Fixed crappy formatting. :)
-CDG10620
Software Developer
Oooh, terrible formatting.![]()
sudo rm -rf /
better?
-CDG10620
Software Developer
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks