the first time you write the trie tree, the template is completely copied.
# Include <iostream> using namespace STD; const int kind = 26; struct treenode {int count; treenode * Next [kind]; treenode () {COUNT = 1; for (INT I = 0; I <kind; ++ I) next [I] = NULL ;}}; void insert (treenode * & root, char * word) {treenode * location = root; int I = 0, branch = 0; If (location = NULL) {location = new treenode (); root = location ;} while (word [I]) {branch = word [I]-'A'; If (location-> next [bra NCH]) location-> next [branch]-> count ++; elselocation-> next [branch] = new treenode (); I ++; location = Location-> next [branch];} int search (treenode * root, char * Word) {treenode * location = root; int I = 0, branch = 0, ans; If (location = NULL) return 0; while (word [I]) {branch = word [I]-'A'; If (! Location-> next [branch]) return 0; I ++; location = Location-> next [branch]; ans = Location-> count;} return ans ;} int main () {char word [10]; char Query [10]; treenode * root = NULL; while (gets (Word )) {If (word [0] = 0) break; insert (root, word);} while (gets (query) cout <search (root, query) <Endl; return 0 ;}