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