Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <bits/stdc++.h>
using namespace std;
struct data
{
string s;
int day,month,year;
}input[101];
bool comp(data x,data y)
{
if(x.year != y.year) return x.year < y.year;
if(x.month != y.month) return x.month < y.month;
return x.day < y.day;
}
int main()
{
int n;
while(cin >> n)
{
for(int i=0;i<n;i++){
string ss;
int x,y,z;
cin >> ss >> x >> y >> z;
input[i].s = ss;
input[i].day = x;
input[i].month = y;
input[i].year = z;
}
sort(input,input+n,comp);
// for(int i=0;i<n;i++) cout << input[i].s << endl;
cout << input[n-1].s << endl << input[0].s << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment