VScode 错误显示数组定义不明确
#include
#include
using namespace std;
int next[100010];
void get_next(string S)
{
next[0]=-1;
next[1]=0;
int i=2;
int cn=0;
while(iif(S[i-1]==S[cn])next[i++]=++cn;
else if(next[cn]>-1)cn=next[cn];
else next[i++]=0;
}
}
int index_KMP(string S,string T)
{
int i=0,j=0;
while(iif(S[i]==T[j]){i++;j++;}
else if(next[j]==-1){i++;}
else j=next[j];
}
if(j>=T.size())return i-T.size();
else return -1;
}
int main()
{
string a,b;
cin>>a>>b;
int cnt=index_KMP(a,b);
cout<;
return 0;
}
next数组换个名称试试呢,提示有二义性
关于该问题,我找了一篇非常好的博客,你可以看看是否有帮助,链接:VSCode无法跳转到外部函数定义