- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- int time;
- cout<<"請輸入你想換算的秒數: ";
- cin>>time;
- cout<<time<<"秒可換算為..."<<endl;
- {
- if(time>=604800)
- {cout<<time/604800<<"週, ";
- time%=604800;}
- if(time>=86400)
- {cout<<time/86400<<"天, ";
- time%=8640;}
- if(time>=3600)
- {cout<<time/3600<<"小時, ";
- time%=3600;}
- if(time>=60)
- {cout<<time/60<<"分鐘, ";
- time%=60;}
- if(time>=1)
- {cout<<time/1<<"秒.";
- time%=1;}
- }
- cout<<endl;
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |