# PAT (Basic Level) Practice （中文）1028 人口普查 求助！！！

Dev-C++输入样例能有正确的输出，但是PTA的编译器给出来的结果和Dev-C++完全不一样，一个测试点也过不了，有大佬能帮忙看一眼问题出在哪里吗？

1028 人口普查 (20分)

​5
​​ ]；随后 N 行，每行给出 1 个人的姓名（由不超过 5 个英文字母组成的字符串）、以及按 yyyy/mm/dd（即年/月/日）格式给出的生日。题目保证最年长和最年轻的人没有并列。

5
John 2001/05/12
Tom 1814/09/06
Ann 2121/01/30
James 1814/09/05
Steve 1967/11/20

3 Tom John

#include<iostream>
#include<cstring>
using namespace std;
long daycounts(int year,int month,int day);
bool isrun(int year);
int main()
{
int n,i;
long max=0,min=1000000;
cin>>n;
int year[n+1],month[n+1],day[n+1],count=0;
char name[n+1][100],p,q,maxname[100],minname[100];
for(i=1;i<=n;i++)
cin>>name[i]>>year[i]>>p>>month[i]>>q>>day[i];
for(i=1;i<=n;i++)
if(daycounts(year[i],month[i],day[i])==0)
;
else
{
count+=1;
if(daycounts(year[i],month[i],day[i])>max)
{
strcpy(maxname,name[i]);
max=daycounts(year[i],month[i],day[i]);
}
if(daycounts(year[i],month[i],day[i])<min)
{
strcpy(minname,name[i]);
min=daycounts(year[i],month[i],day[i]);
}

}
cout<<count<<" ";
for(i=0;maxname[i]!='\0';i++)
cout<<maxname[i];
cout<<" ";
for(i=0;minname[i]!='\0';i++)
cout<<minname[i];
cout<<endl;
return 0;

}

long daycounts(int year,int month,int day)
{
int i,temp;
long sum;
if(year>2014||(year==2014&&month>9)||
(year==2014&&month==9&&day>6))
return 0;
else if(year<1814||(year==1814&&month<9)||
(year==1814&&month==9&&day<6))
return 0;
else
{
switch(month-1)
{
case 11:temp+=30;
case 10:temp+=31;
case 9:temp+=30;
case 8:temp+=31;
case 7:temp+=31;
case 6:temp+=30;
case 5:temp+=31;
case 4:temp+=30;
case 3:temp+=31;
case 2:
if(isrun(year))
temp+=29;
else
temp+=28;
case 1:temp+=31;
}
if(isrun(year))
sum=366-(temp+day);
else
sum=365-(temp+day);
temp=0;
for(i=year;i<=2013;i++)
if(isrun(i))
sum+=366;
else
sum+=365;

sum+=249;
return sum;

}
}

bool isrun(int year)
{
if(year%400==0||(year%4==0&&year%100!=0))
return true;
else
return false;

}



09-22 2625