0 喜歡 0 不喜歡
777 瀏覽

The program below can compare time which is generated by class CTime but it seems not working properly. Please help to fix it. Remember that YOU CAN ONLY ADD YOUR CODE INSIDE THE SPECIFIC AREA

#include <iostream>
#include <cstdlib>
using namespace std;
class CTime
{
   private:
      int hour,min;
      double sec;

   public:

//Your code from here

 

//to here
};

int main(void)
{
   CTime t1(4,13,51.3);
   CTime t2(5,44,30.3);
   
   if(t1>t2)
      cout << "t1 is larger than t2" << endl;
   else
      cout << "t2 is larger than t1" << endl;

   if(t1<t2)
      cout << "t1 is smaller than t2" << endl;
   else
      cout << "t2 is smaller than t1" << endl;
   
   system("pause");
   return 0;
}

 

[練習] Coding (C) - 最新提問 分類:C++ |
ID: 24827 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 777 瀏覽
0 0
Called for Help
0 0
Called for Help
0 0
Called for Help
0 0
Called for Help
0 0
Called for Help

26 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include * ** * ** * **

#include * * * * * ***

using namespace std;

class CTime

{
* * ** *** * ** * *
** * * * * * * ** *** * ** *** * hour,min;
* ** * * * ** ** * *** ** * *** sec;


**** * * ** ** ***** *



//Your code from here
*** * * * *** * ** * h, int m, double s){
**** * **** * *** * * ** *** ***** * * = h;
* *** * * * *** * * * *** * ** * = m;
**** * * ******** **** * * * ** * = s;
* **** * ** ***


* *** * *** **** * * * bool * * * ** (const CTime * * const CTime * ****
*** * *** * * * ******* * **** * **** *** ** * * + num1.min + ** > *** * + num2.min + ** ****
* * ***** **** ** * *


* * *** * * * ** bool **** * (const CTime * ** * const CTime * ** * *
* *** * *** * * *** ***** * * * * * ** * * * + num1.min + num1.sec) < *** *** + num2.min + * * *
*** * * * ** **** **



//to here

};



int *

{
* * * * *** * *** *** ** ***
**** ***** * * *** * *****


** * ** * ******* * **** * ** * * *
** **** * * * * ** * *** ****** ** *** * ** ** is larger than * ** * * *** * ** endl;
* **** ** ** ***
*** * * **** ***** ** **** ** * **** ** ** ******** * is larger than **** * * * * endl;


**** ** ** ***** ***
* ** ** * ** * ** * * ** * ***** * * * * ** is smaller than * ** ** * * * *** endl;
* * * ** * * ** ** ** *
* * * * ** *** * * ** * * *** ** ** * * is smaller than ** * * ** * * endl;


**** * * *** * *** * ** ***
*** * * * * *** * * **** 0;

}
最新回答 用戶: (126 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** * *****

using namespace std;

class CTime

{
******* *** * ** *** *
* * *** ** ***** * * * * * *** hour,min;
* ** * * *** * * * **** * * sec;


* * **** * **



//Your code from here
*** ** *** * * * h, int m, double s){
*** * ** * ** * * *** * ** * * * *** * ** = h;
*** * *** ***** * ** * *** * ** = m;
*** ** * ** * * ****** * ** * ** ***** **** * * = s;
** ** *** *******


* * ** ***** ****** * * bool *** * * (const CTime * * * ** const CTime **** *
* * **** * ** ** * * ** *** * ** * ** + num1.min + * > **** + num2.min + *****
** * * ** *


******** * * * ** bool * * ** (const CTime * ****** * const CTime * *
** * * ** * * * ******** * ****** * * *** * ** ***** + num1.min + num1.sec) < * ** * + num2.min + ***
*** ***** ** ****



//to here

};



int * *

{
* * **** * ** ** **** * * * *
*** ********* ** * * * * * * ** * *


** ** * * ***
*** * * **** * * * * * ** * * * * * * ** ** * ***** * is larger than **** * endl;
** * *** *** *
* ***** * * ** * * *** *** * * * ** *** * * * * * is larger than * ** **** ** endl;


* * ** * *** * * *** *
* ** * **** * * ** * ***** * *** **** ** *** *** * is smaller than ** ** * * * * * endl;
** ** ** * ** *
* ** * **** * * ** * * * ** ** * * ** is smaller than * *** ** * ** * * ** endl;


** * * ** * ***** * * * ** * ****
* * ** ****** * 0;

}
最新回答 用戶: (126 分)
0 喜歡 0 不喜歡
內容已隱藏
#include *** * * *

using namespace std;

class CTime

{
*** ** * * * ***
* *** * ** * *** * * * * **** * hour,min;
* * ** *** * *** *** * ** ** ** ** * * sec;


* ****** ** **** *



//Your code from here
* * *** * ** ** **** *** h, int m, double s){
** * ** *** ** * * * **** * * * **** = h;
** *** * ** ***** * * * **** * **** * * ** = m;
** * ** ***** * ** ****** * * ** * ** * = s;
* ** * * ** * * **


*** * * ** * * ** ** * bool ** * *** ** (const CTime * ***** const CTime **
* * * ** ** * *** ** * * **** * ** ** * * + num1.min + ** ** > * + num2.min + *
* ** * * ***


** **** * * * bool * *** (const CTime * * * ** const CTime ***** *
*** * ** * * ****** **** * ** *** **** * * + num1.min + num1.sec) < * + num2.min + * ****
** **** ****



//to here

};



int * * *

{
** ****** * ** * ** * ** * *
* * * ** * ** * ** * *


* * ** * ** * **
*** *** * **** ***** * * * ** * *** * *** is larger than ** * * * * * ** endl;
** * ****** * * * **
*** *** * * ******* * * * *** **** * **** * * ***** is larger than * * ** *** ** endl;


* *** **** ** * ** * **
* * * * ** *** ***** ** ** ** ** * * * * *** ** **** is smaller than ** * * ***** *** endl;
**** ** *** * **
** * * * ******* * ****** * * * * ** * * * is smaller than ** **** ** endl;


* *** ** * ** ** ** ** * *****
* ** ******** * * ** * 0;

}
最新回答 用戶: (126 分)
0 喜歡 0 不喜歡
內容已隱藏
#include *** ** **** * *

#include ** * * ** *

using namespace std;

class CTime

{
** ** ** **** * ***
** *** * * * * * * ** *** * hour,min;
** * * **** * * * ** ** * ***** * * sec;


** * *** * *
*** * * * ****** * ** * ** ** * *** ** * * ** x,int y,double z){
******* * *** *** **** * **** ** * * * * * ** *** * * ****** ** * = x;
** * * * * * ** * ** ** * **** *** ** *** ** *** *** * * = y;
* *** * ** ** ** * * ***** * ** * * ** ** * * * ** ** * = z;
* ** * ** * ** *** ** * ** * * * * *
* *** ** ** ** *** *** * ** * * ** bool ** *** ** *** * * X, const ** ** * Y);

* **** * *** ** ** * ** * ** bool ** ** *** ** * * X, const * * * * Y);

};



bool operator < (CTime * * *** lhs, CTime *** **** rhs)

{
**** *** ***** *** * * * * * lhs.hour < rhs.hour;

}



bool operator > (CTime *** * lhs, CTime * *** ** rhs)

{
* * *** ** * * **** * * lhs.hour > rhs.hour;

}



int main(void)

{
* * * * * ****** * * *
* * ** *** **** **** ***
* ***** ***
* * ** * ** **** * **
* *** ***** ****** **** **** *** ** *** ** ** * * is larger than * **** * ** * * endl;
*** * * *** * *** * *
** * *** ** * * * * * *** ** * * ** ** ** ** is larger than ** ** ** *** **** endl;


****** **** * ** * * ****** **
** * * ******** ** ** * * * * * ** ** * * * ** ** is smaller than * ******* * ** endl;
* * ** ** * *
** **** ** * * * ***** * *** *** ** * "t2 is smaller than * *** * *** * ** endl;
**** ** ** ** * **
* * * * * * **** * * * ***** * * * *
* * * ** * * ** ***** 0;

}
最新回答 用戶: (237 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * ** * *

#include * * *** ** *

using namespace std;

class CTime

{
****** ***** * ** ** *
** * **** * **** * * ** ** * ** hour,min;
* * * * ***** ** ** ******** ** *** ** ** sec;


*** * * **** * *



//Your code from here
* * *** ** ** * ** * h, int m, double s){
* ***** **** * * ** ***** * * * * ** * * * = h;
*** * * **** * * * ** ** ** * ** = m;
**** * * * ** * * * * * * * * * *** * * = s;
* * ** * * **** * *


* * ** ** * ** ** bool * * * ** * (const CTime ***** const CTime * * *
***** * * ** *** * * **** ** * * * * * * * ** + num1.min + num1.sec) > * ** + num2.min + ** * **
* * * ** * ** *


* * * *** * * ** bool ** ** (const CTime * ***** * const CTime ** * *
* ***** *** * * * ** * ** *** * * ** * ** * * + num1.min + num1.sec) < * * + num2.min + * ****
** * ** ****** **



//to here

};



int ** **

{
** * * ** * ** ** * **** *
* *** * * * * ** ***** * * ***


** * * * *** ** ** **
** ** * * * *** * *** * * ***** * ** **** * * * ** * is larger than * * * ** * * endl;
* * ** ***** * **
*** *** ** * ** **** * * ** *** ** *** ** * * * *** is larger than * * * **** **** * endl;


******* ** ** *** * * * *****
* ** * * * * *** * * ** *** **** ** * * * ** * ** * is smaller than * * * * ** endl;
* ** * ** **
** ** ** ***** * * ***** * **** * ** * *** **** ** * is smaller than * ** * ** **** endl;


*** * * * *** *** * ** * ***
* **** * *** ** 0;

}
最新回答 用戶: (-298 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** * ** *

using namespace std;

class CTime

{
*** ***** * **
**** * *** * * ** ** ** ****** hour,min;
* * ** *** ** * * ** * sec;


* ** * * *



//Your code from here
* * * * * * * h, int m, double s){
* * * ****** **** * ** *** * * **** * * * = h;
** ** ** **** ******* * * *** * **** *** * ** = m;
* ** ** ***** *** * * * * * * ** ** * ** = s;
*** ** * ** * *


* * * ** * ** bool * * * * (const CTime ** ** const CTime * ** **
* * * * ** *** * * * **** * * * ******** *** * **** + num1.min + **** > * * * + num2.min + * * **
* *** * **** * * *


* ***** ** * * bool ******* * (const CTime * * * * const CTime ** * **
* *** * * ***** ** * *** ** *** **** * **** + num1.min + num1.sec) < * + num2.min + ** ***
* * *** *** ***



//to here

};



int * **

{
** **** **** * * ** * * **
* * * ** * * * * *


** ****** **** * *** *** * * *
* ** * ***** **** * ** ***** ** * ** * * ** **** * is larger than * * * ** * **** * endl;
* *** * **
* ** * * * * * ** **** * * *** *** * *** * * * is larger than **** * * * * * endl;


* * * ******* * * * **
**** ** ** * * * ** * ** * *** * ** * * is smaller than ***** * *** * endl;
*** * * * ***** *
* *** ** * * * ***** * ***** * * * * ** * ** * * is smaller than * *** * * ** * endl;


** * * ** ** ** ** *** ***** ** * * **
** * ***** ***** 0;

}
最新回答 用戶: (-298 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** * * ****

#include * ** **

using namespace std;

class CTime

{
**** * * ** ** *** *
** * ** * * * ****** * * *** ** * hour,min;
** * ** * **** * * *** * * * * * sec;


*** * ** **** * **
***** ** * **** ** * * *** **** ** ** * **** x,int y,double z){
**** ** ** * ********* ***** ****** * * * * * ********* * = x;
* * ** ** * * ** * * **** *** * * **** ** * * * * * = y;
* ** * ** ** * ** * * *** ** * * ** * * ** * * * * * * * = z;
* **** ** *** * * ***** * ** **
* **** * ** * *** * * * ** **** ** ** bool * * * ** ***** ** X, const * * * *** Y);

** * ** * * * *** *** * *** * ** * bool ** * ** * * * * * X, const ****** Y);

};



bool operator < (CTime * * ** * lhs, CTime ** *** ** rhs)

{
** * * ** * **** **** ** * lhs.hour < rhs.hour;

}



bool operator > (CTime ** * lhs, CTime * * * * rhs)

{
* * * **** * * ** * *** lhs.hour > rhs.hour;

}



int main(void)

{
** ** ***** **** * * * *
* ** * ****** * *** *
* * * ****** ** * *
* ** * * * * * *** *** ***
* ***** * *** ********* *** ** * *** ** * * * * * ** ** is larger than * *** endl;
*** * ****** * * * * *
* *** * * * * * * ** * * ** * ** * * ** * ** is larger than ** ** * * endl;


* ********** ** *** **
* * * * ***** * * *** ** *** ** * * * * *** * * * is smaller than ** ** ** * * endl;
* * ** ** * *** ** * * *
* * * * * * ** ** * *** ** ** * "t2 is smaller than * * ***** endl;
* * *** ** *
**** * ** * ***** * * * ***** * ** *
** * *** * ** 0;

}
最新回答 用戶: (-215 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** ****

using namespace std;

class CTime

{
*** *** ** * * *****
* * ** * ** ** * * * * **** *** * * hour,min;
* * * * * * *** * * *** ** ** * * * ** sec;


*** ** * * * * ** *****



//Your code from here
***** ** * *** * * ** h, int m, double s){
* *** ** *** *** * ***** ** * * ** ** ** = h;
**** * ***** * * * * ** *** * * = m;
** ** ** * * * *** ** * * *** * * = s;
* **** * ** * *


** * *** * * * bool * * * (const CTime * *** const CTime * ***
** * * * ***** * ** * * *** * * * **** + num1.min + *** > * *** + num2.min + * *
******* * * * *


*** * *** * bool * * * (const CTime ** *** const CTime * **
*** ** * * ** * ** ****** **** ** * * ***** * * + num1.min + num1.sec) < * + num2.min + * * *** *
* ** *** * ******



//to here

};



int * **

{
* * * * **** ** * ** * * *
* ** * * * * * **


**** * * * * * * * * * *
**** *** *** * ** * * ******* * * *** * * * is larger than * ** * * * endl;
* ** * * *** *
*** * * ** * *** * * * ** * * ** * * * ** * *** * * is larger than * * ** *** * endl;


******** ** * * * *
** ** **** * * * * *** * ** ****** *** ** is smaller than *** *** * ** *** endl;
** *** ** *** *
********** * * * ** ****** * * * ** * * * is smaller than *** ****** endl;


* * ** * * * * *** * *** ***
** ** * ** * * ** *** * 0;

}
最新回答 用戶: (-215 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** * * *

using namespace std;

class CTime

{
** * ***** *** * ** * *
*** ** ** ************* * ** * * hour,min;
* *** ** * * ** ****** ******** ** sec;


* * * **** *** * *** *



//Your code from here
* ** * * * * * h, int m, double s){
* **** *** * ** * * ** ** * * ** * * ** ** = h;
** * * ** *** ** ** **** * * * * ** ** **** = m;
****** *** *** * * ** ** ** * * * * *** = s;
********* * **


* * ** * * ** ** * * * bool * ** * * (const CTime * * ****** const CTime * *** *
* * *** * * ** ** ** * *** *** * * * * * * + num1.min + * > * **** + num2.min + ****
* **** ** ** *


* ** ***** ** *** bool * * * * (const CTime * **** const CTime * ***** *
* **** * **** **** *** * **** * *** ** **** + num1.min + num1.sec) < * * + num2.min + * * *
* * ** * * ** * *



//to here

};



int *

{
* ** **** *** * * ** * *
* **** ** ** ** * *****


* ** * *** * * ** **** *
*** ***** ** *** *** * ** * *** ** ** * * is larger than *** * * endl;
** ** * ** ** *
*** * ** ** ** ******* *** * ***** * ** * is larger than ** * * * endl;


*** ** * **** * * *
* * * *** * **** * * ** * * * * * * ** * *** ** is smaller than **** *** *** * endl;
* ** * * ** **
* * * *** * * * ** ** ** ** ** * * * * * is smaller than *** ** * * ** * * endl;


**** * ******* ** * * ** **
*** * ** *** ** *** 0;

}
最新回答 用戶: (-215 分)
0 喜歡 0 不喜歡
內容已隱藏
#include *** ***** *

using namespace std;

class CTime

{
** * * *** * * *
* * * * * * * *** * * ** * hour,min;
******** ***** ****** *** * * * * * sec;


** ** * *** * ** **



//Your code from here
** * *** ** h, int m, double s){
* **** * * *** *** ******* *** = h;
* * * *** ** ** * ** ** ** * * = m;
* ***** ** * * ** * ** ** *** ** = s;
* * * * ** * *** *


** **** * ***** * * * bool * * *** (const CTime * * ** * const CTime * * ** * *
** ** ** ***** *** * ** *** ** ** * + num1.min + * * > * * * + num2.min +
** ** * * * * **


** ** ** ** * ***** * bool * *** * * (const CTime *** * ** * const CTime ***
* * * * * * ****** ** ** * ** * * ** ***** + num1.min + num1.sec) < * ** + num2.min + *
* * ** **



//to here

};



int * ***

{
* ** ** * * * ***
* ** * * ****** *** *** ** *


** * ***** * ** ***
******* * ***** * ** * ** * ** * * * is larger than **** * ** endl;
* * ** * ** * *
*** * ****** * ** ****** * * * ** * ** **** * is larger than ** *** * * ** endl;


* ** * * * *** * **** *
*** ** * *** * * * * ** * **** * * * * * * * is smaller than *** ** * ***** * endl;
* * * ** * * **
* * * * * * *** * * * * * * *** **** * is smaller than * * ** * endl;


* ** * **** *** *** * * *
** * ** * ** ***** 0;

}
最新回答 用戶: (-215 分)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.6.121
©2016-2024

相關問題

0 喜歡 0 不喜歡
15 回答
[練習] Coding (C) - 最新提問 6月 1, 2017 分類:C++ |
ID: 24854 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 510 瀏覽
0 喜歡 0 不喜歡
18 回答
[練習] Coding (C) - 最新提問 5月 25, 2017 分類:C++ |
ID: 24828 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 651 瀏覽
0 喜歡 0 不喜歡
17 回答
[練習] Coding (C) - 最新提問 6月 1, 2017 分類:C++ |
ID: 24855 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 582 瀏覽
0 喜歡 0 不喜歡
30 回答
[練習] Coding (C) - 最新提問 5月 18, 2017 分類:C++ |
ID: 24769 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 769 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶