Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct time {
- int hours;
- int minutes;
- int seconds;
- vector <int> marks;
- };
- bool time_compare(const time& first_time, const time& second_time) {
- if (first_time.hours != second_time.hours) {
- return first_time.hours < second_time.hours;
- }
- else {
- if (first_time.minutes != second_time.minutes) {
- return first_time.minutes < second_time.minutes;
- }
- else {
- if (first_time.seconds != second_time.seconds) {
- return first_time.seconds < second_time.seconds;
- }
- }
- }
- }
- void task3() {
- int n;
- cin >> n;
- vector <time> time_moments(n);
- for (int i = 0; i < n; i++) {
- time current_time;
- int current_hours, current_minutes, current_seconds;
- cin >> current_hours >> current_minutes >> current_seconds;
- current_time.hours = current_hours;
- current_time.minutes = current_minutes;
- current_time.seconds = current_seconds;
- time_moments[i] = current_time;
- }
- stable_sort(time_moments.begin(), time_moments.end(), time_compare);
- for (auto current_time : time_moments) {
- cout << current_time.hours << " " << current_time.minutes << " " << current_time.seconds << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement