0 thích 0 k thích
1.8k đã xem

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;
}

 

[Exercise] Coding (C) - đã hỏi trong C++
ID: 24827 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 1.8k đã xem
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 Trả lời

0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (126 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (126 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (126 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (237 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (-298 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (-298 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (-215 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (-215 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (-215 điểm)
0 thích 0 k thích
Hidden content!
#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;

}
trả lời bởi (-215 điểm)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.127.231
©2016-2024

Những câu hỏi liên quan

0 thích 0 k thích
15 trả lời
[Exercise] Coding (C) - đã hỏi ngày 1 tháng 6 năm 2017 trong C++
ID: 24854 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 1.2k đã xem
0 thích 0 k thích
18 trả lời
[Exercise] Coding (C) - đã hỏi ngày 25 tháng 5 năm 2017 trong C++
ID: 24828 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 1.5k đã xem
0 thích 0 k thích
17 trả lời
[Exercise] Coding (C) - đã hỏi ngày 1 tháng 6 năm 2017 trong C++
ID: 24855 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 1.2k đã xem
0 thích 0 k thích
30 trả lời
[Exercise] Coding (C) - đã hỏi ngày 18 tháng 5 năm 2017 trong C++
ID: 24769 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 1.8k đã xem
12,783 câu hỏi
183,443 trả lời
172,219 bình luận
4,824 thành viên