We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Warmup
  4. Time Conversion
  5. Discussions

Time Conversion

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

    You are viewing a single comment's thread. Return to all comments →

  • ace_dexter 4 years ago+ 1 comment

    Your solution is fine. But the sample input is "07:05:45PM" i.e including ":" (colons). Can you please tell me why did you omit this while taking input? Or is it not necessary?

    0|
    ParentPermalink
    • AbhishekVermaIIT 4 years ago+ 1 comment

      Ultimately, it's up to you how you want to solve it. I found "extracting integers and later printing them with colons" easier than working with strings. Hence, I used scanf+printf for extracting & printing the result.

      0|
      ParentPermalink
      • ace_dexter 4 years ago+ 1 comment

        okay. Also, in scanf, colons doesn't affect input with colons, is it any property of scanf? Like Input is 07:45:54PM and in scanf also, colons are there.

        3|
        ParentPermalink
        • AbhishekVermaIIT 4 years ago+ 0 comments

          scanf() allows us to read input in some specified format as described by the function parameters.

          Colons did affect the input. We used %d:%d:%d to read input of the format hh:mm:ss. If the input had been space separated instead of colons as in hh mm ss, we would have used %d %d %d or simply %d%d%d instead.

          5|
          ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature