View Code of Problem 7

#include <stdio.h>
int main(void) {
    int n,i=0,m,j,s=0;
	int t,a[1000],b[1000],c[1000];
    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 (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;
				}
				s=1;
            }
			if (s)
				printf("UNKNOW\n");
		}
		printf("\n");
        }
        return 0;
   }

Double click to view unformatted code.


Back to problem 7