九度1014 排名/********************************* * 日期:2012-6-29 * 作者:SJF0115 * 题号: 九度1014 * 题目:排名 * 结果:AC * 题意: * 总结:**********************************/#include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct Student{//考号char ID[21];//做出题目数量int num;//做出的题目编号int questionID[11];//总分int totalGrade; }Student;//排序int cmp(const void *a,const void *b){struct Student *c=(Student*)a;struct Student *d=(Student*)b;if(c->totalGrade!=d->totalGrade)return d->totalGrade - c->totalGrade;elsereturn strcmp(c->ID,d->ID);}int main(){int N,M,G;int Grade[11];//输入重定向,输入数据将从in.txt文件中读取//freopen("C:\\Users\\SJF\\Desktop\\in.txt","r",stdin); Student student[1001]; while(scanf("%d",&N)!=EOF) { int i,j,count = 0;if(N == 0){break;}scanf("%d %d",&M,&G);for(i = 0;i<M;i++){scanf("%d",&Grade[i]);}for(i = 0;i<N;i++){scanf("%s %d",&student[i].ID,&student[i].num);student[i].totalGrade = 0;for(j = 0;j<student[i].num;j++){scanf("%d",&student[i].questionID[j]);student[i].totalGrade += Grade[student[i].questionID[j] - 1];}//计算过线人数if(student[i].totalGrade >= G){count ++;}//printf("%s %d %d\n",student[i].ID,student[i].num,student[i].totalGrade);}//输出过线人数printf("%d\n",count);//排序qsort(student,N,sizeof(student[0]),cmp);for(i = 0;i<N;i++){if(student[i].totalGrade >= G){printf("%s %d\n",student[i].ID,student[i].totalGrade);}} } return 0;}