#include <stdio.h>
typedef struct info_person
{
char name[6];
int year;
int mon;
int day;
}InfoPerson;
int main()
{
int N;
scanf("%d",&N);
//============================
InfoPerson person[N];
InfoPerson minperson;
InfoPerson maxperson;
int i;
for(i = 0; i < N ; i ++)
{
scanf("%s %d/%d/%d",person[i].name,&person[i].year,&person[i].mon,&person[i].day);
}
minperson.year = 2014;
minperson.mon = 9;
minperson.day = 7;
maxperson.year = 1814;
maxperson.mon = 9;
maxperson.day = 5;
//=============================================
int count = N; //passed number
for(i = 0; i < N; i ++)
{
if(person[i].year < 1814 || (person[i].year == 1814 && person[i].mon < 9) || (person[i].year == 1814 && person[i].mon == 9 && person[i].day < 6))
{
count --;
continue;
}
if(person[i].year > 2014 || (person[i].year == 2014 && person[i].mon > 9) || (person[i].year == 2014 && person[i].mon == 9 && person[i].day > 6))
{
count --;
continue;
}
if(person[i].year < minperson.year || (person[i].year == minperson.year && person[i].mon < minperson.mon) || (person[i].year == minperson.year && person[i].mon == minperson.mon && person[i].day < minperson.day))
minperson = person[i];
if(person[i].year > maxperson.year ||(person[i].year == maxperson.year && person[i].mon > maxperson.mon) || (person[i].year == maxperson.year && person[i].mon == maxperson.mon && person[i].day > maxperson.day))
maxperson = person[i];
}
if(count == 0)//test 3
{
printf("0");
}
else
printf("%d %s %s",count,minperson.name,maxperson.name);
return 0;
}
PTA1028-C语言-人口普查
最新推荐文章于 2022-04-24 14:25:01 发布