View Code of Problem 444

//
//  444_Who is Older?.cpp
//  ZjgsOj
//
//  Created by aran on 2022/3/11.
//

#include <iostream>
#include <algorithm>
using namespace::std;

struct people{
    int year,month,day;
    string name;
};

int cmp(people a,people b){
    if (a.year != b.year)
        return a.year < b.year;
    else if(a.month != b.month)
        return a.month < b.month;
    else
        return a.day < b.day;
}

int main()
{
    int T;
    cin >> T;
    for (int i = 0; i < T; i++) {
        people p[2];
        p[0].name = "javaman";
        p[1].name = "cpcs";
        cin >> p[0].year >> p[0].month >> p[0].day;
        cin >> p[1].year >> p[1].month >> p[1].day;
        if (p[0].year == p[1].year && p[0].month == p[1].month && p[0].day == p[1].day)
            cout << "same" << endl;
        else{
            sort(p, p+2, cmp);
            cout << p[0].name << endl;
        }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 444