voidinsert(char s[], int len){ int now = 0; for (int i = 0; i < len; i++) { int x = s[i] - 'a'; if (!node[now][x]) { node[now][x] = ++cnt; } now = node[now][x]; } isend[now] = 1; }
字典树的查找
1 2 3 4 5 6 7 8 9 10 11
boolsearch(char s[], int len){ int now = 0; for (int i = 0; i < len; i++) { int x = s[i] - 'a'; if (!node[now][x]) { returnfalse; } now = node[now][x]; } return isend[now]; }