將輸入的分鐘數, 換算成幾天幾小時幾分鐘.
程式執行參考畫面如下:
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- cout<<"請輸入想換算的分鐘數: ";
- int mins;
- cin>>mins;
- cout<<mins<<"分鐘可換算為..."<<endl;
- if(mins>=(60*24)){
- cout<<mins/(60*24)<<"天, ";
- mins=mins%(60*24);
- }
- if(mins>=60){
- cout<<mins/60<<"小時, ";
- mins=mins%60;
- }
- if(mins>=1){
- cout<<mins<<"分鐘.";
- }
-
- cout<<endl;
-
- system("pause");
- return 0;
- }
複製代碼 |