#include <iostream> using namespace std; class Time { public: int hours; // 小时 int minutes; // 分钟 Time() { hours = 0; minutes = 0; } Time(int h, int m) { this->hours = h; this->minutes = m; } void show() { cout << hours << " " << minutes << endl; } // write your code here...... bool operator<(const Time& t) { return hours < t.hours || hours == t.hours && minutes < t.minutes; } }; int main() { int h, m; cin >> h; cin >> m; Time t1(h, m); Time t2(6, 6); if (t1 < t2) cout << "yes"; else cout << "no"; return 0; }
#include<iostream> using namespace std; class Time { private: int hours, minutes; public: Time(int hours, int minutes) { this->hours = hours; this->minutes = minutes; } bool operator<(const Time& t) { if (this->hours < t.hours) return true; else if (this->hours == t.hours && this->minutes < t.minutes) return true; else return false; } }; void test01() { int h, m; cin >> h >> m; Time t1(h, m), t2(6, 6); cout<<(t1 < t2 ? "yes" : "no" )<< endl; } int main() { test01(); return 0; }
#include <iostream> using namespace std; class Time { public: int hours; // 小时 int minutes; // 分钟 Time(int h, int m) { //构造函数 hours = h; minutes = m; } int operator<(Time& t) { int flag; hours < t.hours ? flag = 1 : (hours == t.hours ? (minutes < t.minutes ? flag = 1 : flag = 0) : flag = 0); return flag; } ~Time(){} }; int main() { int h, m; cin >> h >>m; Time t1(h, m); Time t2(6, 6); if(t1<t2) cout<< "yes"; else cout << "no"; return 0; }