- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
- int x;
- cout<<"請輸入你要換算的秒數:"<<endl;
- cin>>x;
- cout<<x<<"秒可以換算成: ";
- 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>=1){
- cout<<x<<"秒";
- }
- cout<<endl;
- system("pause");
- }
複製代碼 |