bool CountSubStr(char * pShortString, char * pLongString)
{
/*在这里实现功能*/
int lens,lenl,i,j,cmpcount = 0;
if(NULL == pShortString && NULL == pLongString)
{
return false;
}
lens = (int)strlen(pShortString);
lenl = (int)strlen(pLongString);
if(0 == lens||0 == lenl)
{
return false;
}
for(j = 0; j < lenl; ++j)
{
for(i = 0; i < lens; ++i)
{
if (*(pShortString+i) != '?')
{
if(*(pShortString+i) == *(pLongString+j))
{
cmpcount++;
}
else
{
i=0;
break;
}
}
else
{
if(*(pShortString+i+1) == *(pLongString+j+1))
{
cmpcount++;
}
else if(*(pShortString+i+1) == *(pLongString+j+2))
{
cmpcount++;
cmpcount++;
}
else if(*(pShortString+i+1) == *(pLongString+j+3))
{
cmpcount++;
cmpcount++;
cmpcount++;
}
else
{
i=0;
break;
}
}
}
}
if(cmpcount < lens)
{
return -1;
}
else
return cmpcount;
}
阅读(339) | 评论(0) | 转发(0) |