Thread: switch hours and minutes

  1. #1

    Unhappy switch hours and minutes


    I am trying to calculate the number of times that hh:mm hours and minutes in a 24 hour period can be interchanged and still be a valid time.

    example 5:10 can be switched to 10:5
    22:40 can not be switched 40:20

    I am clueless on how to tackle this problem

    need help!!!!!

  2. #2
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Why is this a C problem ?????????
    Anyway a hint is
    mm has to be less than or equal to the maximum value hh can take , which is ......
    The one who says it cannot be done should never interrupt the one who is doing it.

  3. #3
    Registered User
    Join Date
    Aug 2001
    so what you're saying is that you need an allgorithm?

    This is sinple, all hour values can be valid minute values, but only the first 12 (or 24, depending on how you keep time) minute values can be hour values, so check to see if the minutes <= 12 or 24, and if they are, the answer is possible to interchange them. Now you can write your code.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time between Military Hours
    By StarOrbs in forum C++ Programming
    Replies: 18
    Last Post: 03-01-2005, 06:46 PM
  2. Algo for create hours and minutes with given seconds
    By BianConiglio in forum C Programming
    Replies: 6
    Last Post: 05-30-2004, 06:50 PM
  3. Difference b/ween hours into minutes??
    By CodeFuse in forum C++ Programming
    Replies: 2
    Last Post: 03-22-2003, 02:01 AM
  4. please help me fix my coding for this assignment
    By sayeem81 in forum C Programming
    Replies: 1
    Last Post: 01-29-2002, 02:45 AM
  5. Converting MInutes to Hours and MInutes
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 08-30-2001, 08:07 PM