cpp_primer_plus/ch03/04.cpp
2022-08-23 23:01:08 +01:00

17 lines
646 B
C++

# include <iostream>
# include <cmath>
using namespace std;
long convt = 60;
long convd = 24;
int main(){
long time_all;
cout << "Enter the number of seconds: ";
cin >> time_all;
int day, hour, minute, second;
day = time_all / pow(convt,2) / convd;
hour = (time_all - day * pow(convt,2) * convd)/ pow(convt,2);
minute = (time_all - day * pow(convt,2) * convd - hour * pow(convt,2)) / pow (convt,1);
second = time_all - day * pow(convt,2) * convd - hour * pow(convt,2) - minute * pow (convt,1);
cout << time_all << " secods = " << day << " days, " << hour << " hours, " << minute << " minutes, " << second << " seoncds\n";
return 0;
}