View Code of Problem 7

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

/*
Main.c: In function 'main':
Main.c:20:29: error: expected expression before '!=' token
                 if (a[b[i]])!=0{
                             ^
Main.c:3:17: warning: unused variable 's' [-Wunused-variable]
     int n,i,m,j,s=0,x,y,max=1;
                 ^
Main.c:3:15: warning: unused variable 'j' [-Wunused-variable]
     int n,i,m,j,s=0,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