BF算法
//BF算法
#include <iostream>
using namespace std;
int BF(char S[], char T[])
{
int index = 0, i = 0, j = 0;
while (S[i] != '\0' && T[j] != '\0')
{
if (S[i] == T[j])
{
i ++;
j ++;
}
else
{
index ++;
i = index;
j = 0;
}
}
if (T[j] == '\0')
return index + 1;
else
return 0;
}
int main()
{
char S[100] = "abcdefg";
char T[100] = "bc";
cout << BF(S, T) << endl;
return 0;
}
本文来自博客园,作者:逆袭怪,转载请注明原文链接:https://www.cnblogs.com/fghjktgbijn/p/17377951.html