Use of the ultraviolet A 156 map
Background: learn knowledge about map. For details, refer to the code.
My code:
# Include
# Include
# Include
# Include
Using namespace std; map
Map1; map
Map2; vector
Vector1, ans; string string+lower (string string1) {for (int I = 0; I <string1.size (); I ++) string1 [I] = tolower (string1 [I]); sort (string1.begin (), string1.end (); // because string defines four arithmetic operations and Relational operators, return string1;} int main (void) {string string1, string2; while (cin> string1 & string1! = "#") {Vector1.push _ back (string1); string1 = string1_lower (string1); if (map1.count (string1) = 0) map1 [string1] = 0; // use map first. count () to check whether the key exists. Map1 [string1] ++; // directly use the key as the subscript to access the second element} for (int I = 0; I <vector1.size (); I ++) {if (map1 [string1_lower (vector1 [I])] = 1) ans. push_back (vector1 [I]);} sort (ans. begin (), ans. end (); for (vector
: Iterator it = ans. begin (); it! = Ans. end (); it ++) cout <* it <