View Code of Problem 7

#include <stdio.h>
int main(void) {
    int n,i,m,s,x,y,max=1;
	int t,a[10000]={0},b[10000];
    scanf("%d",&n);
    while (n--){
        scanf("%d",&t);
        for (i=0;i<t;i++){
            scanf("%d=%d",&x,&y);
			a[x]=y;
			a[y]=x;
		}
        scanf("%d",&m);
        for (i=0;i<m;i++){
            scanf("%d",&b[i]);
			if (max<b[i])
			max=b[i];
		}
			for (i=0;i<max;i++){
				s=b[i];
                if (a[s]!=0){
                   printf("%d\n",a[s]);
				   break;
				}
                printf("UNKNOW\n");
				}
		printf("\n");
        }
        return 0;
   }

Double click to view unformatted code.


Back to problem 7