#include #include #include using namespace std;

int main() { map<string, string> dictionary; string line; while (getline(cin, line) && line != "") { // 读入字典 string english, foreign; int space_pos = line.find(' '); english = line.substr(0, space_pos); foreign = line.substr(space_pos + 1); dictionary[foreign] = english; } while (cin >> line) { // 读入待翻译的单词 if (dictionary.find(line) != dictionary.end()) { // 查找字典 cout << dictionary[line] << endl; } else { cout << "eh" << endl; } } return 0; }

C++ 实现二分查找算法在线翻译外语单词

原文地址: https://www.cveoy.top/t/topic/nM2z 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录