His sister's, knocked out, the computer crashed, all disappeared, and again ,... What is the pace?
# Include <stdio. h> # include <string. h> # include <stdlib. h> # define zero 0 # define alph_len 26/* 26 letters */const char first_char = 'a'; typedef struct node {struct node * child [alph_len]; /* store the next character */int n;/* record the number of times the current word appears */} node, * node; node root; /* The root node of the dictionary tree (no characters are stored) * // * Insert the word */void insert (char * Str) {int I, index, Len; node current = NULL, newnode = NULL; Len = strlen (STR); current = root;/* the current node is Root Node */for (I = 0; I <Len; I ++)/* Insert characters one by one */{Index = STR [I]-first_char; /* obtain the subscript of this character */If (current-> child [Index]! = NULL)/* The character is already in the dictionary tree */{current = Current-> child [Index];/* modify the current node location */(current-> N) + +;/* The current word appears again. If the character */} else/* has not appeared, the node */{newnode = (node) calloc (1, sizeof (node);/* Add a node and initialize */current-> child [Index] = newnode; current = newnode; /* modify the current node location */current-> n = 1; /* this new word appears */}/* search for the word */INT find_word (char * Str) {int I, index, Len; node current = NULL; Len = strlen (Str ); Current = root;/* Search Start from the root node */for (I = 0; I <Len; I ++) {Index = STR [I]-first_char; /* obtain the subscript of this character */If (current-> child [Index]! = NULL)/* The current character exists in the dictionary tree */{current = Current-> child [Index];/* modify the location of the current node */} else {return zero; /* the word does not match after comparison. The dictionary tree does not contain the word */} Return Current-> N; /* Number of times this word appears */} int main () {char TMP [11]; int I; root = (node) calloc (1, sizeof (node )); while (gets (TMP), strcmp (TMP ,"")! = Zero) {insert (TMP);} while (scanf ("% s", TMP )! = EOF) {I = find_word (TMP); printf ("% d \ n", I);} return 0 ;}