View Code of Problem 7

#include<stdio.h>
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		int a[100][2];
		int b[100];
		int c[100];
		int flag;
		scanf("%d",&n);//表示有n个等式 
		for(int i=0;i<n;i++){
			scanf("%d=%d",&a[i][0],&a[i][1]);
		}
		int m;
		scanf("%d",&m);//表示要对比几个数字 
		for(int i=0;i<m;i++){
			scanf("%d",&b[i]);//这里是要转换的数字
		}								//用b[]与C[]与之前的a[][]中找匹配 
		for(int i=0;i<m;i++) {
			flag=0;
			for(int j=0;j<n;j++){
			//n是代表有n的等式 
				if(b[i]==a[j][0]){
					printf("%d\n",a[j][1]);
					flag=1;
					break;
				}
				if(b[i]==a[j][1]){
					printf("%d\n",a[j][0]);
					flag=1;
					break;
				}	
			}
			if(flag==0){
				printf("UNKNOW\n");
			}
			
		}
		
		printf("\n");
	} 
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 7