设为首页 加入收藏

TOP

C语言实现二叉树-利用二叉树统计单词数目(二)
2015-11-10 13:46:16 来源: 作者: 【 】 浏览:29
Tags:语言 实现 利用 统计 单词 数目
e * tree) {
? ? if(tree) {
? ? ? ? deltree(tree->left);
? ? ? ? deltree(tree->right);
? ? ? ? free(tree);
? ? }
}


void print_inorder(node * tree) {
? ? if(tree) {
? ? ? ? print_inorder(tree->left);
? ? ? ? printf("[%s\t\t\t]count:[%d]\n",tree->str,tree->count);
? ? ? ? print_inorder(tree->right);
? ? }
}



int main(int argc, char ** argv)
{
? ? node * root;
? ? node * tmp;
? ? //int i;


? ? root = NULL;
? ? /* Inserting nodes into tree */
? ? insert(&root,"hello");
? ? insert(&root,"hey");
? ? insert(&root,"hello");
? ? insert(&root,"ok");
? ? insert(&root,"hey");
? ? insert(&root,"hey");
? ? insert(&root,"hey");



? ? printf("In Order Display\n");
? ? print_inorder(root);



? ? /* Deleting all nodes of tree */


? ? deltree(root);
}


最后运行结果如下:



Discussion


那么这个程序已经完成啦!


还有很多可以优化的,也可以增加更多的功能;


例如,查找特定字符出现的次数;


或者特定字符所出现的行数,等等都可以;


我们会在日后慢慢完善;


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言实现二叉树 下一篇C语言实现冒泡排序-整数排序

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: