返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5.     int x;
  6.     cout<<"請輸入你要換算的秒數:"<<endl;
  7.     cin>>x;
  8.     cout<<x<<"秒可以換算成: ";
  9.     if(x>=604800){
  10.         cout<<x/604800<<"周 ";
  11.         x=x%604800;
  12.     }
  13.     if(x>=86400){
  14.         cout<<x/86400<<"天 ";
  15.         x=x%86400;
  16.     }
  17.     if(x>=3600){
  18.         cout<<x/3600<<"小時 ";
  19.         x=x%3600;
  20.     }
  21.     if(x>=60){
  22.         cout<<x/60<<"分鐘 ";
  23.         x=x%60;
  24.     }
  25.     if(x>=1){
  26.         cout<<x<<"秒";
  27.     }


  28. cout<<endl;
  29. system("pause");
  30. }
複製代碼

TOP

返回列表