Write a program that, given a number of seconds n, prints the number of hours, minutes and seconds represented by n.
Input: Input consists of a natural number n.
Output: Print three natural numbers h, m, s such that 3600h+60m+s=n, with m<60 and s<60.
Input: Input consists of a natural number n.
Output: Print three natural numbers h, m, s such that 3600h+60m+s=n, with m<60 and s<60.
#include <iostream> using namespace std; int main (){ int n; cin >> n; int h, m, s; h = n/3600; s = n%60; m = (n-s-(3600*h))/60; cout << h <<' '<< m << ' ' << s << endl; }
No comments:
Post a Comment