有 n 條已讀消息,m 條新到達消息(不區分大小寫)。求未讀消息條數(即在已讀集合中但不在新到達集合中的消息數)。
set。
#include
#include
#include
#include
using namespace std;
int main() {
int n, m;
while (cin >> n && n) {
cin >> m;
set read;
for (int i = 0; i < n; ++i) {
string s; cin >> s;
for (char &c : s) c = tolower(c);
read.insert(s);
}
for (int i = 0; i < m; ++i) {
string s; cin >> s;
for (char &c : s) c = tolower(c);
if (read.count(s)) read.erase(s);
}
cout << read.size() << endl;
}
return 0;
}