Home > Back-end >  For help, who can explain this code
For help, who can explain this code

Time:09-27

# include "stdio.h"
# include "string. H"
Void get_next (char T [], int next [])
{//"abcaabbcabcaabdab
"Int I=1;
Next [1]=0;
int j=0;
Int length=strlen (T) - 1;
While (iIf (j==0 | | T [I] T [j])=={
+ + I; + + j;
Next [I]=j;
}
The else
J=next [j];
}
}
Int main ()
{
Char [] s="abcaabbcabcaabdab";
Int n [18];
Get_next (s, n);
int i;
for(i=1; i<18; I++)
Printf (" % d ", n [I]);

return 0;

}

CodePudding user response:

The location of the statistical characters appear?

CodePudding user response:

KMP algorithm, baidu,,,,,

CodePudding user response:

String matching algorithm, KMP algorithm is the data structure

CodePudding user response:

Don't understand is debugging!
 
If (j==0 | | T [I] T [j])=={
+ + I; + + j;
Next [I]=j;
Printf (" % d j=I=% d % d % d \ n ", __LINE__, I, j, next [I]);
}
The else
{
J=next [j];
Printf (" % d j=% d % d \ n ", __LINE__, j, next [j]);
}
  • Related