View Code of Problem 7

#include <stdio.h>
int main()
{
	int i, b, c, d[1000], a[100000], m, n, t;
	scanf("%d", &t);
	while (t--)
	{
		for (i = 0; i < 100000; i++)
		{
			a[i] = -1;
		}
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d=%d", &b, &c);
			a[b] = c;
			a[c] = b;
		}
		scanf("%d", &m);
		for (i = 0; i < m; i++)
		{
			scanf("%d", &b);
			d[i] = a[b];
		}
		for (i = 0; i < m; i++)
		{
			if (d[i] != -1)
				printf("%d\n", d[i]);
			else
				printf("UNKNOW\n");
		}
		if(t>=1)
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 7