--- title: "字符串匹配" created: 2025-11-28 tags: - 算法 --- # 字符串匹配 ## 题目 [字符串匹配](https://www.acwing.com/problem/content/description/3531/) ![[image-8065e45d.png]] ## 思路分析 把[]中间部分当成一个字符位进行比较 把[]中的东西提出来 用find进行匹配 ## 代码实现 ```cpp #include using namespace std; const int N=1010; string strs[N],p; int n; string to_lower(string s){ string res; for(auto c:s) res+=tolower(c); return res; } bool match(string a,string b){ //a串中没括号 每轮++即可 b串可能有括号 手动移动指针 for(int i=0,j=0;i>n; for(int i=0;i>strs[i]; } cin>>p; p=to_lower(p); for(int i=0;i