// Name : Trie树
// Parameter : tnode:要插入单词的节点的父节点的指针 word:单词
// Return : 无
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int maxc=30;
typedef struct TrieNode{
int voc; // 这个节点表示的单词有几个
TrieNode *kid[maxc];
TrieNode(){ voc=0; memset(kid,-1,sizeof(kid)); }
}Trie;
Trie *root=new Trie();
void AddVoc(TrieNode * tnode,char * word){
int l=strlen(word);
TrieNode *p=tnode;
for(int i=0;i<l;i++){
int idx=word[i]-'a';
if(tnode->kid[idx]==NULL) tnode->kid[idx]=new TrieNode();
p=tnode->kid[idx];
}
p->voc++;
}
int main(){
AddVoc(root,"hello");
return 0;
}