数据结构哈夫曼编码c语言.docVIP

  • 14
  • 0
  • 约4.11千字
  • 约 6页
  • 2017-01-25 发布于重庆
  • 举报
数据结构哈夫曼编码c语言

数据结构哈夫曼编码c语言实现 #include stdafx.h #includeiostream.h #includestdio.h #includestdlib.h #includestring.h #includefstream.h typedef struct{ //赫夫曼树的结构体 char ch; int weight; //权值 int parent,lchild,rchild; }htnode,*hfmtree; typedef char **hfmcode; void Select(hfmtree HT,int a,int *p1,int *p2) //Select函数,选出HT树到a为止,权值最小且parent为0的2个节点 { int i,j,x,y; for(j=1;j=a;++j){ if(HT[j].parent==0){ x=j; break; } } for(i=j+1;i=a;++i){ if(HT[i].weightHT[x].weightHT[i].parent==0){ x=i; //选出最小的节点 } } for(j=1;j=a;++j) { if(HT[j].parent==0x!=j) {

文档评论(0)

1亿VIP精品文档

相关文档