This topic let me understand a little map container, so this question is still my view of the problem, the less I see the better ....
Map is the map, well, it's easy to use, there is the get () will read newline characters ... GetChar () can also, but scanf () these
Formatted to not be able to attend ... Will exist inside the buffer
Code:
#include <stdio.h> #include <iostream> #include <string.h> #include <stdlib.h> #include < String> #include <map>using namespace Std;map<string,string>map;char a[25];char S[25];char D[25];char b [25];void init () {map.clear ();} int main () {int i,j;while (gets (a)) {if (a[0] = = ' i=0 ') break;int len = strlen (a); for (i<len;; i++ a[i) {if (] = = ") break; int k=0; for (j=0; j<i; j + +) s[k++] = A[j];k = 0;for (j=i+1; j<len; j + +) d[k++] = A[j]; MAP[D] = s;} while (gets (b)) {if (Map.find (b)!=map.end ()) cout << Map[b] <<endl;elseputs ("eh");} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
UVA 10282 Babelfish (map)