201409-3 字符串匹配

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n, type;
string s, p;
string tolower(string s) {
	string res;
	for (char c : s) res += tolower(c);
	return res;
}
int main() {
	cin >> p >> type >> n;
	
	while (n--) {
		cin >> s;
		if (type && s.find(p) != -1) cout << s << endl;
		else if (!type && tolower(s).find(tolower(p)) != -1) cout << s << endl;
	}
	
	return 0;
}



















