|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
int main()
{
struct date
{
int year;
int mouth;
int day;
}date[200];
int a;
while(scanf("%d",&a)!=EOF)
{
int b,c;
for(b=0;b<a;b++)
{
scanf("%d-%d-%d",&date[b].year,&date[b].mouth,&date[b].day);
}
for(c=a-1;c>0;c--)
{
if(date[c].year<date[c-1].year)
{
date[c-1]=date[c];
}
else if(date[a].year==date[a-1].year)
{
if(date[c].mouth<date[c-1].mouth)
{
date[c-1]=date[c];
}
else if(date[c].mouth==date[c-1].mouth)
{
if(date[c].day<=date[c-1].day)
{
date[c-1]=date[c];
// printf("%d\n",c);
}
}
}
printf("%d %d-%0.2d-%0.2d\n",c,date[c-1].year,date[c-1].mouth,date[c-1].day);
}
printf("%d-%0.2d-%0.2d\n",date[0].year,date[0].mouth,date[0].day);
}
} |
|