标签:pre init int sea i++ str search turn oid
struct trie { void insert1(char *str) { int len = strlen(str); int root = 0; for (int i = 0; i < len; i++) { int id = str[i] - ‘a‘; if (tree[root][id]) { tree[root][id] = ++tot; } root = tree[root][id]; } flag[root] = 1; } bool search(char *str) { int len = strlen(str); int root = 0; for (int i = 0; i < len; i++) { int id = str[i] - ‘a‘; if (!tree[root][id]) { return 0; } root = tree[root][id]; } return 1; } void init() { for (int i = 0; i < tot; i++) { flag[i] = 0; for (int j = 0; j < 10; j++) { tree[i][j] = 0; } } tot = 0; } }
标签:pre init int sea i++ str search turn oid
原文地址:https://www.cnblogs.com/Accpted/p/11272691.html