#include <iostream>
#include <string>
using namespace std;
string calculate(int seconds) {
int secondsPerMinute = 60;
int secondsPerHour = secondsPerMinute * 60;
int secondsPerDay = secondsPerHour * 24;
int days = seconds / secondsPerDay;
seconds %= secondsPerDay;
int hours = seconds / secondsPerHour;
seconds %= secondsPerHour;
int minutes = seconds / secondsPerMinute;
seconds %= secondsPerMinute;
string result =
"Days: " + to_string(days) +
"\nHours: " + to_string(hours) +
"\nMinutes: " + to_string(minutes) +
"\nSeconds: " + to_string(seconds);
return result;
}
int main() {
int seconds;
cin >> seconds;
cout << calculate(seconds);
return 0;
}
Comments
Leave a comment