此问题为:
问str1是否有str2
#include <iostream>
#include <string>
using namespace std;
bool match(string strLong,string strShort)
{
size_t sS = strShort.length();
size_t lS = strLong.length();
int j;
bool isMactch = true;
for(int i = 0; i <= lS-sS; i++)
{
for(j = 0; j < sS; j++)
{
if (strLong[i+j] != strShort[j])
{
break;
}
}
if(j==sS)
return true;
}
return false;
}
int main()
{
if(match("abc","abd"))
cout<<"Yes"<<endl;
else{
cout<<"No"<<endl;
}
}