Home > Back-end >  A simple string
A simple string

Time:11-09

# include
# include
Void Index (char [] S, char T [], int pos, int next [])//use patterns on the next function of T o T in the main chain S after the first pos characters in the location of the KMP algorithm,
{//which, T is not empty, 1 & lt;=pos<=S [0]
Int I=pos, j=1;
While (i<=S [0] & amp; & j<=T [0])
{if (j==0 | | S==[I] T [j])
{+ + I;
+ + j;
}
The else j=next [j];
}
If (j>=T [0]) printf (" mode in the main chain of the position is: % 3 d ", I - T [0]).
Else printf (" does not exist in the master list and pattern string equal to the string ");
}
Void main ()
{char [] S="ababbaabaa";//0 unit to store the number of characters in the string
Char T []="aab";//0 unit to store the number of characters in the string
Int I, j, pos=0;
Int next [100];//next [I] said when the mode of the ith character and the main series of the corresponding characters' mismatch ',
//in the pattern string need to and the main character of comparing the character in the string location
S [0]=strlen (S) - 1;
T [0]=strlen (T) - 1;
Printf (" S [0]=% d ", S [0]).
Printf (" T [0]=% d ", T [0]).
i=1;
Next [1]=0;
J=0;
While (I {if (j==0 | | T==[I] T [j])
{+ + I;
+ + j;
Next [I]=j;
}
The else j=next [j];
}
for(i=1; i<[0]=T; I++)
Printf (" % 3 d ", next [I]);
Printf (" please enter your to find from the main list of which of the characters: ");
The scanf (" % d ", & amp; Pos);
The Index (S, T, pos, next);
}
//you can run, I just do

CodePudding user response:

What's the problem? Problem description!
  • Related