It is a very difficult question, but it takes a lot of effort to process the space between the two rows. In the end, char is used, because it can be modified freely. Compared with the string, the insert function is more flexible. You can also use hash to do this, but it is troublesome.
# Include <iostream> # include <string> # include <map> # include <cstdio> using namespace std; int main () {char d1 [50], d2 [50]; string tp; map <string, string> dic; int count = 0; while (1) {char t = getchar (); if (t = '\ n') break; else {d1 [0] = t; int I = 1; while (1) {t = getchar (); if (t = '') {d1 [I] = '\ 0'; break;} elsed1 [I ++] = t ;}} cin >> d2; getchar (); // eat the carriage return letter dic [d2] = d1; count ++;} string tar after the foreign input; while (cin> tar) {map <string, string> :: iterator p = dic. find (tar); if (p = dic. end () cout <"eh" <endl; elsecout <(* p ). second <endl;} return 0 ;}