Time decomposition (2) P22654


Statement
 

pdf   zip   main.cc

thehtml

Write a procedure

void decompose(int n, int& h, int& m, int& s);

that, given a quantity of seconds n, computes how many hours h, minutes m and seconds s it represents. That is, we must have s + 60m + 3600h = n, with 0≤ s <60 and 0≤ m <60.

Precondition

n is a natural number.

Observation You only need to submit the required procedure; your main program will be ignored.

Public test cases
  • Input/Output

    decompose(147) → 0 2 27
    decompose(100000) → 27 46 40
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++