/*****************************************************************
* Enter the number fo seconds:31600000
* 31600000-seconds = 365 days, 17 hours, 46 minutes, 40-seconds.
*****************************************************************/
#include <iostream>
using namespace std;
int main() {
long timeSeconds;
int seconds;
const int day_persent = 24 * 60 * 60;
const int hour_persent = 60 * 60;
const int minute_persent = 60;
cout << "Enter the number fo seconds:";
cin >> seconds;
timeSeconds = seconds;
cout << timeSeconds << "-seconds = " << timeSeconds / day_persent << " days, "
<< timeSeconds % day_persent / hour_persent << " hours, "
<< timeSeconds % day_persent % hour_persent / minute_persent << " minutes, "
<< timeSeconds % day_persent % hour_persent % minute_persent << "-seconds." << endl;
}
时间转换<将秒转换为天、小时、分钟>
最新推荐文章于 2023-02-08 14:24:54 发布