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