View Code of Problem 7

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

Double click to view unformatted code.


Back to problem 7