pat乙级1028第一个测试点

题目如下:

我的代码:

#include <stdio.h>

struct person{
        char name[6];
        int year, month, day;
    };

bool is_older(person a, person b);
bool is_younger(person a, person b);

int main(){
    int N, count_p=0, oldest=0, youngest=0;
    scanf("%d", &N);
    person p[N];
    person left = {"left", 1814, 9, 6};
    person right = {"right", 2014, 9, 6};
    for(int i=0; i<N; i++){
        scanf("%s %d/%d/%d", p[i].name, &p[i].year, &p[i].month, &p[i].day);
        if(is_older(p[i], left) || is_younger(p[i], right)) continue;
        count_p++;
        if(is_older(p[i], p[oldest])) oldest = i;
        else if(is_younger(p[i], p[youngest])) youngest = i;
    }
    if(count_p==0) printf("0");
    else printf("%d %s %s", count_p, p[oldest].name, p[youngest].name);

    return 0;
}

bool is_older(person a, person b){
    if(a.year != b.year) return a.year<b.year;
    else if(a.month != b.month) return a.month<b.month;
    else return a.day<b.day;
}

bool is_younger(person a, person b){
    if(a.year != b.year) return a.year>b.year;
    else if(a.month != b.month) return a.month>b.month;
    else return a.day>b.day;
}

提交后第一个测试点过不了:
在这里插入图片描述
找不到错误,求大神看看哪里错了。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值