@[Watchman](/space/show?uid=177228)
```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, m,kount=0;
// cin >> n >> m;
// scanf("\n");
scanf("%d %d\n",&n,&m);
vector<string> gaoshou(n);
vector<string> her(m);
for (int i = 0; i < n; i++)
{
getline(cin,gaoshou[i]);
while(!isalpha(gaoshou[i].back()))gaoshou[i].pop_back();
}
for (int i = 0; i < m; i++)
{
getline(cin,her[i]);
while(!isalpha(her[i].back()))her[i].pop_back();
}
for (int i = 0; i < m; i++)
{
for(int j=0;j<n;j++)
if (gaoshou[j] == her[i])
{
kount++;
break;
}
}
cout << kount;
//system("pause");
}
```
by Smile_Cindy @ 2019-03-21 09:49:22
~~我不会,可以瞎搞~~
by 已注销%Jm9VScx @ 2019-03-21 12:27:35
作者: longyuxuan 更新时间: 2017-06-18 11:39 在Ta的博客查看 6
这题很简单,但是为什么有些人AC不了呢?
第一,读入完数字之后应该吧数字后面的换行符吃掉
第二,地点可能会有空格
第三,经过我的多次测试后发现落谷有个bug(也不知道是不是bug),就是使用getline之后会在字符后面加一个ASCLL码为13的字符,这就是有些人在自己机子上过了可是第一个测试点没过的原因
C++的AC代码如下
#include<bits/stdc++.h>//万能头文件~=~
using namespace std;
string gs[21],ll;
int n,m,ans=0;
int main()
{
cin>>n>>m;
getline(cin,ll);//把数字后面没用的东西吃掉,防止读入出错
for(int i=1;i<=n;i++)
getline(cin,gs[i]);//地名可能会有空格,注意了
for(int i=1;i<=m;i++)
{
getline(cin,ll);
if(ll[ll.size()-1]!=13)ll=ll+(char)13;//应对这个bug的方法,在机子上测试不用这句
for(int j=1;j<=n;j++)
if(ll==gs[j])
{
ans++;
break;
}
}
cout<<ans;
return 0;
}
by Hhggi @ 2019-04-14 15:41:18
@[Hhggi](/space/show?uid=182796)
# markdown!!!
by 幻影学霸刘 @ 2019-04-25 21:24:19