?? secondschange.cpp
字號:
//p64 4.編寫一個程序,要求用戶以整數方式輸入秒數(使用long變量存儲),然后以天,小時,分鐘和秒的方式顯示
//這段時間.使用符號常量來表示每天有多少小時,每小時有多少分鐘以及每分鐘有多少秒.
//完成于8月10日7:13
#include <iostream>
int main()
{
using namespace std;
const int DayInHours=24; //一天有24小時
const int HourInMinutes=60; //一小時有60分鐘
const int MinuteInSeconds=60; //一分鐘有60秒
long seconds;
long days;
long hours;
long minutes;
cout<<"Enter the number of seconds:";
cin>>seconds;
minutes = seconds/MinuteInSeconds; //先把秒全轉換成分鐘
seconds% = MinuteInSeconds; //余數則求出秒
hours = minutes/HourInMinutes; //再把分鐘全轉換成小時
minutes% = HourInMinutes; //此時則求出分鐘
days = hours/DayInHours; //然后把小時全轉換成天同時求出天
hours% = DayInHours; //最終求出小時
cout<<seconds<<" seconds="
<<days<<" days,"
<<minutes<<" minutes,"
<<seconds<<" seconds."
<<endl;
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -