Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<iostream>#include<string>using namespace std;#define MAX 26struct trie_node//node{int count;trie_node *next[MAX];};void node_insert(trie_node *root,string s)//insert a new string{if(root==NULL||s.size()==0)return;int i=0;trie_node *p=root;while(s[i]!='\0'){if(s[i]>='a'&&s[i]<='z'){if(p->next[s[i]-'a']==NULL)//if do not exit,build a new node;{/* build a new node */trie_node *temp=new trie_node;temp->count=0;for(int j=0;j<MAX;j++)temp->next[j]=NULL;p->next[s[i]-'a']=temp;//change p}