B1028 人口普查

#include <cstdio>
#include <string.h>
struct info{
    char name[10];
    char birth[15];
}temp,max,min;
int main(){
    int k,count=0;
    char str1[15]="2014/09/07";
    char str2[15]="1814/09/05";
    strcpy(max.birth,str2);
    strcpy(min.birth,str1);
    scanf("%d",&k);
    while(k--){
        scanf("%s%s",temp.name,temp.birth);
        if(strcmp(temp.birth,str2)>0&&strcmp(temp.birth,str1)<0){
            count++;
            if(strcmp(temp.birth,max.birth)>0)
                max=temp;
            if(strcmp(temp.birth,min.birth)<0)
                min=temp;
        }
    }
    if(!count)
        printf("0");
    else
        printf("%d %s %s",count,min.name,max.name);
    return 0;
}

个人感觉比晴神答案好点,有现成的轮子为什么不用呢?

 

posted on 2021-01-20 21:42  臭小孩  阅读(31)  评论(0)    收藏  举报

导航