思路
- 字符串处理
- 合理使用find()函数,当查询不到对应字符串时,返回
string::npos
。 - 注意输入需要按行读入
getline(cin, str)
代码
#include <iostream>
#include <string>
using namespace std;
int main()
{
int m, n;
cin>>m>>n;
getchar();
int useful = 0;
string str, res;
for(int i = 0; i < m; i++){
getline(cin, str);
if(str.find("qiandao") != string::npos || str.find("easy")!= string::npos)
continue;
else n--;
if(n < 0) res = str;
}
if(n >= 0) cout<<"Wo AK le"<<endl;
else cout<<res<<endl;
return 0;
}