标签:style blog http io for html
结构体定义没搞明白,一直WA,终于AC了,真是高兴呀
代码如下:
#include<stdio.h> #include<stdlib.h> #include<string.h> struct student { char id[30]; int score; }person[1001]; int cmp(const void *a,const void *b) { struct student *aa=(struct student *)a; struct student *bb=(struct student *)b; if(aa->score!=bb->score) return bb->score-aa->score; else return strcmp(aa->id,bb->id); } int main() { int N,M,G,i,title[11],sum,tihao[10],m,j; while( scanf("%d%d%d",&N,&M,&G)!=EOF,N) { int count=0; for(i=1;i<=1001;i++) person[i].score=0; for(i=1;i<=M;i++) scanf("%d",&title[i]); for(i=1;i<=N;i++) { scanf("%s%d",person[i].id,&m); for(j=1;j<=m;j++) { scanf("%d",&tihao[j]); person[i].score+=title[tihao[j]]; } } qsort(person+1,N,sizeof(person[1]),cmp); for(i=1;i<=N;i++) { if(person[i].score>=G) count++; } printf("%d\n",count); for(i=1;i<=N;i++) { if(person[i].score>=G) printf("%s %d\n",person[i].id,person[i].score); } } return 0; }
标签:style blog http io for html
原文地址:http://blog.csdn.net/lihaogegehuting/article/details/37934831