View Code of Problem 7

#include<iostream>
using namespace std;
int main() {
	int case_count;
	int rule_count;
	int query_count;
	int query;
	int a, b;
	map<int, int> dic;
	cin >> case_count;
	for (int i = 0; i< case_count; ++i) {
		cin >> rule_count;
		for (int j = 0; j<rule_count; ++j) {
			scanf("%d=%d", &a, &b);
			dic[a] = b;
			dic[b] = a;
		}
		cin >> query_count;
		for (int j = 0; j < query_count; ++j) {
			cin >> query;
			map<int, int>::iterator result = dic.find(query);
			if (result != dic.end())
				cout << result->second << endl;
			else cout << "UNKNOW" << endl;
		}
		cout << endl;
	}
	return 0;
}
/*
Main.cc: In function 'int main()':
Main.cc:9:2: error: 'map' was not declared in this scope
  map<int, int> dic;
  ^
Main.cc:9:6: error: expected primary-expression before 'int'
  map<int, int> dic;
      ^
Main.cc:15:4: error: 'dic' was not declared in this scope
    dic[a] = b;
    ^
Main.cc:21:8: error: expected primary-expression before 'int'
    map<int, int>::iterator result = dic.find(query);
        ^
Main.cc:22:8: error: 'result' was not declared in this scope
    if (result != dic.end())
        ^
Main.cc:22:18: error: 'dic' was not declared in this scope
    if (result != dic.end())
                  ^
*/

Double click to view unformatted code.


Back to problem 7