#include<bits/stdc++.h>
using namespace std;
bool cmp(char a,char b)
{
if(a==b||a-'A'+'a'==b||a-'a'+'A'==b)return true;
return false;
}
bool match(string a,string b,int i,int j)
{
while(j<b.size())
{
if(a[i]=='?')
{
i++;
j++;
continue;
}
else if(a[i]!='*')
{
if(cmp(a[i],b[i]))
{
i++;
j++;
continue;
}
else return false;
}
else if(a[i]=='*')
{
if(i==a.size()-1)return true;
for(int k=0;k<b.size();k++)
{
if(match(a,b,i+1,k))
return true;
}
return false;
}
}
if(i!=a.size()||j!=b.size())return false;
return true;
}
int main()
{
string a,b;
while(cin>>a>>b)
{
if(match(a,b,0,0))cout<<"true"<<endl;
else cout<<"false"<<endl;
}
return 0;
}
字符串通配符
最新推荐文章于 2020-12-03 04:38:21 发布