标签:style blog http io color ar os sp for
题目地址:1194. Message Flood
思路:
不区分大小写,先全部转化为小写,用stl提供的函数做会很方便。
具体代码如下:
1 #include <iostream> 2 #include <set> 3 #include <string> 4 using namespace std; 5 6 int main() { 7 int n, m; 8 while (cin >> n && n) { 9 cin >> m; 10 set<string> v; 11 for (int i = 0; i < n; i++) { 12 string temp; 13 cin >> temp; 14 for (int j = 0; j < temp.size(); j++) { //全部转化为小写 15 temp[j] = tolower(temp[j]); 16 } 17 v.insert(temp); 18 } 19 for (int i = 0; i < m; i++) { 20 string temp; 21 cin >> temp; 22 for (int j = 0; j < temp.size(); j++) { 23 temp[j] = tolower(temp[j]); 24 } 25 if (v.count(temp)) 26 v.erase(temp); 27 } 28 cout << v.size() << endl; 29 } 30 31 return 0; 32 }
标签:style blog http io color ar os sp for
原文地址:http://www.cnblogs.com/winray/p/4095665.html