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