返回列表 發帖

時間換算機

將輸入的分鐘數, 換算成幾天幾小時幾分鐘.
程式執行參考畫面如下:

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int m,h,d;
  7.     cout>>"輸入要換算der分鐘">>endl;
  8.     cin<<m;
  9.     h=m/60;
  10.     m=m%60;
  11.     d=h/24;
  12.     h=h%24;
  13.     cout>>"可換成"<<d<<"天"<<h<<"小時"<<m<<"分鐘"<endl;
  14.     system("pause");
  15.     return 0;
  16. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     cout<<"時間"<<endl;
  7.     int m , h , d ;
  8.     cin >> m;
  9.     h=m/60;
  10.     m=m%60;
  11.     d=h/24;
  12.     h=h%24;
  13.     cout<<"當m 值為"<<m<<",h 值為"<<h<<"當d值為"<<d<<"<<endl;
  14.    
  15.    
  16.    
  17.      system("pause");
  18.     return 0;
  19. }
複製代碼

TOP

本帖最後由 蔡季樺 於 2016-2-13 11:04 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int m;
  7.     cout<<"請輸入想換算的分鐘數:";
  8.     cin>>m;
  9.     cout<<m<<"分鐘換算為..."<<endl;
  10.     cout<<m/(24*60)<<"天,";
  11.     m%=(24*60);
  12.     cout<<m/60<<"小時,";
  13.     m%=60;
  14.     cout<<m<<"分鐘"<<endl;
  15.     system("pause");
  16.     return 0;   
  17. }
複製代碼

TOP

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int m, h, d, M;
  7.     cout << "輸入要換算的分鐘:";
  8.     cin >> m;
  9.     M = m;
  10.     h = m / 60;
  11.     m = m % 60;
  12.     d = h / 24;
  13.     h = h % 24;
  14.     cout << M << "分鐘可換成" << endl;
  15.     cout << "可換成" << d << "天" << h << "小時" << m << "分鐘" << endl;
  16.     system("pause");
  17.     return 0;
  18. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int m;
  7.     cout << "請輸入想換算的分鐘數:";
  8.     cin >> m;
  9.     cout << m << "分鐘換算為..." << endl;
  10.     cout << m / (24 * 60) << "天,";
  11.     m %=(24 * 60);
  12.     cout << m / 60 << "小時,";
  13.     m%=60;
  14.     cout << m << "分鐘" << endl;
  15.     system("pause");
  16.     return 0;
  17. }
複製代碼

TOP

返回列表