View Code of Problem 7

#include<stdio.h>
int main()
{
	int t;
	int a[1000],b[1000],c[1000];
	int i,j,k,temp;
	scanf("%d",&t);
	for (i=0;i<t;i++)
	{
		int m;
		scanf("%d",&m);
		for (k=0;k<m;k++)
		{
			scanf("%d=%d",&a[k],&b[k]);
		}
		int n;
		scanf("%d",&n);
		for (j=0;j<n;j++)
		{
			scanf("%d",&c[j]);
		}
		for (j=0;j<n;j++)
		{
			temp=0;
			for (k=0;k<m;k++)
			{
				if (c[j]==a[k])
				{
					printf("%d\n",b[k]);
					temp=1;
					break;
				}
				if (c[j]==b[k])
				{
					printf("%d\n",a[k]);
					temp=1;
					break;
				}
			}
			if (temp==0)
			{
				printf("UNKNOW\n");
			}
		}
		printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 7