#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
string temp;
vector<string> encrypt, decrypt;
int i,n, co=0;
cin >> n;
for(i=0;i<n;i++)
{
cin >> temp;
encrypt.push_back(temp);
}
for(i=0;i<n;i++)
{
cin >> temp;
decrypt.push_back(temp);
}
for(i=0;i<n;i++)
{
temp = encrypt[i];
if((binary_search(decrypt.begin(), decrypt.end(), temp)) == true) ++co;
}
cout << co << endl;
return 0;
}
它读取两个相等的字符串列表,并且应该打印出第一个列表中有多少单词也在第二个列表中找到,简单。没有给我expexted结果,我认为问题出在binary_search。你能告诉我为什么吗 ?