/ ************************************************** ************** * String Match Uty @ uaty * Algorithm: First, the location of each character in the string is first recorded in the list array ANSI, characters The ASCII value is a * array index. When the same character occurs once, the corresponding linked list adds a node * matching, each character of the target is used as an index to find the location of the search string *, if The value of each location is incremented in turn, indicating that the destination string appears in the string to be searched, ************************************* **************************************************** / # include
TypedEf struct _node {int value; // Location struct _node * next; bool isnext; // of the character is located in the destination string of the next} node, * pnode; pnode ANSI [256 ]; // ------------------------------------------------------------------------------------------------------------------------ ---------------------- DWord main (void) {char SourceString [1024] = "Aabbccdfffff"; char searching [1024] = "b"; int i ; Int Ret; for (i = 0; i <256; i ) ANSI [i] = null;
Lookupthesource (SourceString, 1024); // Positions to the position of each character in the string to appear in the list array ANSI RET = DOTHESEARCHING (Searching, Strlen (Searching)); // Matching Process Printf ("% S / N% S / N ", SourceString, Searching; Printf ("% D / N ", RET); return 0;} // ------------------------ ------------------------------------------ DWORD LOOKUPTHESOSOURCE (Char * SOURCE , intleth) {INT I; PNODE TEMP; for (i = 0; i
} Else {for (Temp = ANSI [Source [i]]; Temp-> Next! = NULL; TEMP = Temp-> Next); temp-> next = (pnode) malloc (sizeof (node)); TEMP-> Next-> value = i; temp-> next -> next = null; Temp-> Next -> isnext = false;}} return 0;} // --------------- -------------------------------------------------- --- DWord Dothesearch (CHAR * STR, INT Length) {INT I; PNODE TEMP; for (i = 0; I
/ ************************************************** ************** * String Match Uty @ uaty * Algorithm: First, the location of each character in the string is first recorded in the list array ANSI, characters The ASCII value is a * array index. When the same character occurs once, the corresponding linked list adds a node * matching, each character of the target is used as an index to find the location of the search string *, if The value of each location is incremented in turn, indicating that the destination string appears in the string to be searched, ************************************* **************************************************** / # include
For (i = 0; I