#include #include #include typedef struct peoples{ int year; int month; int day; char gender[10]; int births; } Peo; typedef struct people{ int year; int F; int M; int ALL; int cha; } Peop; typedef struct years{ int year; int births; } Year; void clean(int i,Peo *peo){ if(peo[i].year%4!=0&&peo[i].year%100==0||peo[i].year%400!=0){ if(peo[i].month==2&&peo[i].day==29){ peo[i].births=0;} } if((peo[i].month==2&&peo[i].day==30)||(peo[i].month==2&&peo[i].day==31)){ peo[i].births=0;} if(peo[i].month==4&&peo[i].day==31){ peo[i].births=0;} if(peo[i].month==6&&peo[i].day==31){ peo[i].births=0;} if(peo[i].month==9&&peo[i].day==31){ peo[i].births=0;} if(peo[i].month==11&&peo[i].day==31){ peo[i].births=0;} } void init(Peo *peo,char *b,int i){ char s[5]=","; peo[i].year=atoi(strtok(b,s)); peo[i].month=atoi(strtok(NULL, s)); peo[i].day=atoi(strtok(NULL, s)); strcpy(peo[i].gender,strtok(NULL,s)); peo[i].births=atoi(strtok(NULL,s)); } Peo *read(char *t){ FILE *fp; fp=fopen(t,"r"); char buff[500]; int q=15547; Peo *peo; peo=(Peo*)malloc(sizeof(Peo)*(q)); fgets(buff,500,fp); int i; for(i=0;i<15547;i++){ fgets(buff,500,fp); init(peo,buff,i); } fclose(fp); return peo; } void display(Peo *peo){ int i; printf("年份\t月份\t天份\t性别\t出生人数\n"); for(i=0;i<15547;i++){ printf("%d\t%d\t%d\t%s\t%d\n",peo[i].year,peo[i].month,peo[i].day,peo[i].gender,peo[i].births); } } void form(Peo *peo,Peop *peop,int a[]){ int i,e,j,k; a[0]=0; printf("year\tF\t\tM\t\tALL\t\tF-M\n"); peop=(Peop*)malloc(sizeof(Peop)*(5)); peop[0].year=1960; for( i=0;i<15547;i++){ if(peo[i].year==1969){ a[1]=i+1; peop[1].year=peo[i+1].year; } if(peo[i].year==1979){ a[2]=i+1; peop[2].year=peo[i+1].year; } if(peo[i].year==1989){ a[3]=i+1; peop[3].year=peo[i+1].year; } if(peo[i].year==1999){ a[4]=i+1; peop[4].year=peo[i+1].year; } if(peo[i].year==2008){ a[5]=i+1; peop[5].year=peo[i+1].year; } } int sumC=0,sum=0,sumf=0,summ=0; for( i=0;i<5;i++){ for( j=a[i];j(*(Year*)b).births?1:-1; } void sort(Peo *peo,int d[],Year *year,int c[]){ int j,h,q,u,e,w; year=(Year*)malloc(sizeof(Year)*(40)); for( j=0;j<40;j++){ for( h=0;h<15547;h++){ if(peo[h].year==d[j]){ c[j]=h; } } } int sum=0,sum1=0; for(j=0;jmax){ max=las[u].births; month01=las[u].month; day01=las[u].day; } if(las[u].births!=0&&las[u].births