Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>using namespace std;#define MAX 26typedef struct TrieTree {int count;struct TrieTree *next[MAX];}TrieTree;TrieTree *insert(TrieTree **root, const char *s){if (*root == NULL && s == NULL)return NULL;TrieTree *index = *root;while (*s != '\0'){int tmp = (*s) - 'a';if (index->next[tmp] != NULL){index = index->next[tmp];index->count++;}else{TrieTree *newnode = new TrieTree;for (int i = 0; i < MAX; i++)newnode->next[i] = NULL;newnode->count = 1;