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