标签:字典树 turn sizeof class search == div roo build
char s[11]; int n,m; bool p; struct node { int count; node * next[26]; }*root; node * build() { node * k=new(node); k->count=0; memset(k->next,0,sizeof(k->next)); return k; } void insert() { node * r=root; char * word=s; while(*word) { int id=*word-‘a‘; if(r->next[id]==NULL) r->next[id]=build(); r=r->next[id]; r->count++; word++; } } int search() { node * r=root; char * word=s; while(*word) { int id=*word-‘a‘; r=r->next[id]; if(r==NULL) return 0; word++; } return r->count; }
标签:字典树 turn sizeof class search == div roo build
原文地址:https://www.cnblogs.com/ww123/p/9095108.html