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