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: 10ms
Memory: 1092kB
Author: 2015210405033
In contest: 1043

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct fun{
	char name[101];
	int fen;
};
 int main()
 {
	 struct fun x[1000],w;
 int a,t,b,c,d,e,g,h;
 char y[100];
 scanf("%d",&a);
for(b=0;b<a;b++)
	scanf("%s %d",x[b].name,&x[b].fen);
for(b=0;b<a-1;b++)
{
	for(c=b;c<a;c++)
		{
			if(x[b].fen<x[c].fen)
			{
				w=x[b];
			x[b]=x[c];
			x[c]=w;
			}
	}
}
			scanf("%d",&c);
while(c--)
{
	scanf("%s",y);
	d=strlen(y);
	for(e=0;e<a;e++)
	{
		g=0;
	for(b=0;b<d;b++)
	{
		if(y[b]==x[e].name[b])
			g++;
	}
	if(g==d)
	{
		h=0;
		for(b=0;b<e;b++)
			if(x[e].fen<x[b].fen)
				h++;
		printf("%d\n",h);
		break;
	}
	}
}
 }