Start: Dec, 27, 2015 17:15:00
2015年秋学期《程序设计基础》第三次上机考试
End: Dec, 27, 2015 20:45:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 2ms
Memory: 1792kB
Author: 2015210405021
In contest: 1043

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
struct chengji
{
	char name[200];
	double score;
	int number;
};
int comp(const void*p,const void*q)
{
	return((struct chengji*)q)->score-((struct chengji*)p)->score;
}
int main(void)
{
	struct chengji a[2000];
	int i,n,t,j,p=0;
	char b[2000][200];
	while(scanf("%d",&n)!=EOF)
	{
	for(i=0;i<n;++i)
	{
		scanf("%s%lf",a[i].name,&a[i].score);
	}
	qsort(a,n,sizeof(struct chengji),comp);
	a[0].number=0;
	for(i=1;i<n;++i)
	{
		if(a[i].score==a[i-1].score)
		{
			a[i].number=a[i-1].number;
			++p;
		}
		else
		a[i].number=i;
	}
	scanf("%d",&t);
	for(i=0;i<t;++i)
	{
		scanf("%s",b[i]);
		strcat(b[i],":");
	}
	for(i=0;i<t;++i)
	{
		for(j=0;j<n;++j)
		{
			if(strcmp(b[i],a[j].name)==0)
				printf("%d\n",a[j].number);
		}
	}
	}
	return 0;
}