Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#include<climits>#include<algorithm>using namespace std;const int MAX=26;const int N=30;struct Trie //Trie结点声明{bool isStr;//标记该结点处是否构成一个串int prefix;//统计前缀Trie *next[MAX];//一个指针数组,存放着指向各个儿子节点的指针};void insert(Trie *root,const char *s) //将单词s插入到字典树中{if(root==NULL||*s=='\0')return;Trie *p=root;while(*s){if(p->next[*s-'a']==NULL)//如果不存在存储该字符的节点,则建立结点{Trie *temp=new Trie;for(int i=0; i<MAX; i++){temp->next[i]=NULL;