Social Icons

Thursday, November 26, 2015

Solve of UVA 12541: Birthdates

Solve of UVA 12541: Birthdates



#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct persn
{
    char name[20];
    int day,month,year;
};

bool cmp(persn a,persn b)
{
    if(a.year == b. year )
    {
        if(a.month == b. month )
            return a.day<b.day;
        else return a.month < b.month;
    }

    return a.year<b.year;
}

int main()
{
    persn pr[111];
    int n,i,j,k,l,d,m,y;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>pr[i].name>>pr[i].day>>pr[i].month>>pr[i].year;
    }
    sort(pr,pr+n,cmp);

    cout<<pr[n-1].name<<endl<<pr[0].name<<endl;
    return 0;

}

No comments:

Post a Comment

 

Sample text

Sample Text

 
Blogger Templates