poj2001字典树
来源:互联网 发布:优化相机 编辑:程序博客网 时间:2024/06/05 02:34
#include <cstdio>#include <cstring>using namespace std;typedef char st[22];st str[20003];st s;int p=0;struct tree_node{ int count; tree_node *next[26];}root ,node[20003];void insert(char *word){ tree_node *location=&root; while (*word) { if (location ->next[*word-'a']==NULL) { node[p].count=0; location->next[*word-'a']=&node[p++]; } location =location->next[*word-'a']; location->count++; word++; }}void search(char *word){tree_node *location=&root; while (*word&&location) { if (location->count ==1) break; printf("%c",*word); location=location->next[*word-'a']; word++; } printf("%\n"); return;}int main(){ int i=0; while (scanf("%s",str[i])!=EOF) { insert(str[i]); i++; } int n=i; for (i=0;i<n;i++) { printf("%s ",str[i]); search(str[i]); } return 0;}
0 0
- POJ2001字典树
- poj2001(字典树)
- poj2001 字典树
- POJ2001 字典树
- poj2001字典树
- poj2001字典树
- POJ2001 字典树
- poj2001(字典树)
- POJ2001字典树
- POJ2001 字典树
- POJ2001 - Shortest Prefixes - 字典树
- POJ2001 Shortest Prefixes【字典树】
- 【poj2001】Shortest Prefixes 字典树
- POJ2001 Shortest Prefixes(字典树)
- 字典树模板(poj2001验证)
- POJ2001 - 字典树(trie)的模板题
- POJ2001 字典树(模版题)
- POJ2001 Shortest Prefixes(字典树)
- 交叉排序
- Android Drawable、Bitmap、byte[]之间的转换
- 确定天数 SDUT 2520
- HDu 1513 LCS
- JVM学习笔记(四)------内存调优
- poj2001字典树
- Java的package和import机制
- Cocos2d-js 3.0 颜色变换(调整sprite/图片的色调)
- Excel格式导入导出数据(单语言版本)
- 字符串hash
- 八大排序算法(一)直接插入排序
- 初学数据库
- map和hash_map性能测试
- 计算几何模板 ——求多边形有多少条对称轴