博文
构造键树并打印显示(2008-08-21 13:17:00)
摘要:前些日子做了一个输入法,用到键树研究了一下,此树又叫字典树。#include<iostream>#include<cstring>#include<vector>#include<algorithm>#include<windows.h>#include<fstream>using namespace std;//数据结构://以键树为数据结构,采用孩子兄弟链表存储typedef struct Node{ char ch; //存拼音字母 int Count; //存以ch为前缀的拼音数 int Index; //存第一个以ch为前缀的索引 struct Node* pChild; //子结点 struct Node* pBrother; //兄弟结点}PinYin, *pPinYin;typedef PinYin const* cpPinYin;//拼音森林,每个开头的字母为一棵树PinYin PinYinTree[26];//初始化每棵树的根void Init(){ int i; for(i = 0; i < 26; ++i){ ......
