#include#include#include#include#includetypedef struct /赫夫曼树的结构体char ch;int weight; /权值int parent,lchild,rchild;htnode,*hfmtree;typedef char *hfmcode;void Select(hfmtree for(j=1;jy)*p1=y;*p2=x;else*p1=x;*p2=y;void hfmcoding(hfmtree int p1,p2;char *cd,z;if(nchoice;if(choice=I|choice=i) /初始化赫夫曼树coutn;hfmcoding(HT,HC,n);for(i=1;icode;couth;input_file.close();output_file.open(“Textfile.txt“);if(!output_file)couth; couthendl;input_file.close();cout“译码结束,字符已经存入 Textfile.txt 文件中!“endl;else if(choice=Q|choice=q) /退出程序 exit(0);else /如果选了选项之外的就让用户重新选择cout“您没有输入正确的步骤,请重新输入!“endl;coutendl;return 0;