#include <stdio.h>
#include <ctype.h>
int Match(char *str, char *p)
{
bool flag=false;
if(str==NULL||p==NULL)return 0;
while(*str!='\0'&&*p!='\0')
{
if(tolower(*str)==tolower(*p))
{
str++;
p++;
}
else
{
if(*p=='[')
{
do
{
p++;
if(tolower(*p)==tolower(*str))
{
flag=true;
str++;
do
{
p++;
}while(*p!=']');
}
}while(*p!=']');
if(flag=false)return 0;
else p++;
}
else
{
return 0;
}
}
}
if(*str=='\0'&&*p=='\0')return 1;
else return 0;
}
int main()
{
char a[1000][30],rgx[30];
char (*pa)[30]=a,*prgx=rgx;
int n,i;
while(scanf("%d",&n)!=EOF)
{
for(i=0; i<n; i++)
{
scanf("%s",pa+i);
}
scanf("%s",prgx);
for(i=0; i<n; i++)
{
if(Match((char*)(pa+i),prgx))printf("%d %s\n",i+1,pa+i);
}
}
}
九度1165:字符串匹配
最新推荐文章于 2023-02-28 02:35:06 发布