View Code of Problem 7

#include <stdio.h>
int main(void) {
    int n,i,m,j,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;
   }

/*
Main.c: In function 'main':
Main.c:21:26: error: expected expression before '!=' token
                 if (a[s])!=0){
                          ^
Main.c:21:29: error: expected statement before ')' token
                 if (a[s])!=0){
                             ^
Main.c:3:15: warning: unused variable 'j' [-Wunused-variable]
     int n,i,m,j,s,x,y,max=1;
               ^
Main.c: At top level:
Main.c:30:10: error: expected declaration specifiers or '...' before string constant
   printf("\n");
          ^
Main.c:31:9: error: expected identifier or '(' before '}' token
         }
         ^
Main.c:32:9: error: expected identifier or '(' before 'return'
         return 0;
         ^
Main.c:33:4: error: expected identifier or '(' before '}' token
    }
    ^
*/

Double click to view unformatted code.


Back to problem 7