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: 46ms
Memory: 1276kB
Author: 2015210405010
In contest: 1043

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct f{
	char a[100],c[100];
	int x;
};
int comp(const void *p,const void *q){
	return ((struct f *)q)->x-((struct f *)p)->x;
}
void main()
{
	struct f b[1001];
	int i,j,k,h,n,m,z;
	char c[1000][100];
	scanf("%d",&n);
	for(i=0;i<n;++i)
	scanf("%s %d",&b[i].a,&b[i].x);
	qsort(b,n,sizeof(struct f),comp);
	scanf("%d",&m);
	for(j=0;j<m;++j)
	{
	    scanf("%s",&c[j]);
		for(h=0;h<n;++h)
		{
			z=0;
		for(k=0;k<strlen(c[j]);++k)
			{
				if(c[j][k]==b[h].a[k])
					z++;
		    }
		if(z==strlen(c[j]))
		{
			for(i=0;i<n;++i)
			{
				if(b[h].x==b[i].x)
				{
					printf("%d\n",i);
					break;
				}
			}
		}
		}
		}
	}