#include <iostream> #include<map> #include<string> using namespace std; //把魔咒一整个的存下来 map<string, string>dic; int main() { string str; while (getline(cin, str)) { // 注意 while 处理多个 case if (str == "@END@")break; //先全部存起来 int pos = str.find(']'); string zhouyu_with, mofa,zhouyu; zhouyu_with = str.substr(0, pos+1);//要连中括号一起保存,这样的话要简单一点 zhouyu = str.substr(1, pos -1); mofa = str.substr(pos + 2); dic[zhouyu_with] = mofa; dic[mofa] = zhouyu; } int n; cin >> n; getchar(); while (n--) { string key; getline(cin, key); if (!dic.count(key))printf("what?\n"); else printf("%s\n", dic[key].c_str()); } } // 64 位输出请用 printf("%lld")