返回列表 發帖
本帖最後由 陳育霖 於 2023-12-23 13:41 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<iomanip>
  4. using namespace std;
  5. int main()
  6. {
  7.     int a;
  8.     cout<<"請輸入您想換算的秒數: ";
  9.     cin>>a;
  10.     cout<<a<<"秒可換算為..."<<endl;
  11.         cout<<a/604800<<"週, ";
  12.         a=a%604800;
  13.         cout<<a/86400<<"天, ";
  14.         a=a%86400;
  15.         cout<<a/3600<<"小時, ";
  16.         a=a%3600;
  17.         cout<<a/60<<"分鐘, ";
  18.         a=a%60;
  19.         cout<<a<<"秒."<<endl;
  20.         system("pause");
  21.         return 0;
  22. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<iomanip>
  4. using namespace std;
  5. int main()
  6. {
  7.     int a;
  8.     cout << "請輸入您想換算的秒數: ";
  9.     cin >> a;
  10.     cout << a << "秒可換算為..." << endl;
  11.     if(a/604800>1)
  12.     cout << a / 604800 << "週, ";
  13.     a = a % 604800;
  14.     if (a / 86400 > 1)
  15.     cout << a / 86400 << "天, ";
  16.     a = a % 86400;
  17.     if (a / 3600 > 1)
  18.     cout << a / 3600 << "小時, ";
  19.     a = a % 3600;
  20.     if (a / 60 > 1)
  21.     cout << a / 60 << "分鐘, ";
  22.     a = a % 60;
  23.     if (a > 0)
  24.     cout << a << "秒." << endl;
  25.     system("pause");
  26.     return 0;
  27. }
複製代碼

TOP

返回列表