PAT-B1028测试点4不通过

题目:https://pintia.cn/problem-sets/994805260223102976/exam/problems/994805293282607104

img


代码如下,望各位指导修改!


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {char n[6];int y;int m;int d;} student;
int judge(int a,int b,int c)
{
    if(a == 2014 && b <= 9)
    {
        if(b == 9 && c > 6)
            return 0;
        return 1;
    }
    else if(a == 1814 && b >= 9)
    {
        if(b == 9 && c < 6)
            return 0;
        return 1;
    }
    else if(a > 1814 && a < 2014)
        return 1;
    return 0;
}
int compare(const void* x,const void* y)
{
    student m = *(student*)x;
    student n = *(student*)y;
    if(m.y<n.y)
            return -1;
        else if(m.m == n.m)
        {
            if(m.m < n.m)
                return -1;
            else if(m.m == n.m)
            {
                if(m.d<n.d)
                    return -1;
            }
            return 1;
        }
    }
    return 1;
}
int main()
{
    int N,i,temp=0;
    scanf("%d",&N);
    student stu[N];
    for(i=0;i<N;i++)
    {
        char name[6];
        int year,month,day;
        scanf("%s %d/%d/%d",name,&year,&month,&day);
        switch(judge(year,month,day))
        {
            case 1:
                {
                    strcpy(stu[temp].n,name);
                    stu[temp].y=year;
                    stu[temp].d=day;
                    temp++;
                    break;
                }
            case 0:
                break;
        }
    }
    qsort(stu,temp,sizeof(stu[0]),compare);
    printf("%d",temp);
    if(temp != 0)
        printf(" %s %s\n",stu[0].n,stu[temp-1].n);
    else
        printf("\n");
    return 0;
}