数据结构课程设计报告
string str,enstr=\
char temp[26]; //存放不同的字符 int weight[26]; //存放不同字符的权值 cout<<\请输入要编译的字符串:\ getline(cin,str);
cout<<\这个字符串的长度为:\ int m=str.length(); int *flag=new int[m];
for(int t=0;t if(flag[t]==0)//取出不同字符 { temp[j]=str[t]; weight[j]=1; for(int k=t+1;k if(temp[j]==str[k]&&flag[k]==0) { flag[k]=1; weight[j]++; } } j++; } } cout<<\在这串字符串中存在的字符种类是\种\HaffNode *myhafftree=new HaffNode[2*j-1]; Code *myhaffcode=new Code[j]; Haffman(weight,j,myhafftree,temp); bianma(myhafftree,j,myhaffcode,temp); for(t=0;t for(int k=0;k if(myhaffcode[k].value==str[t]) { for(int s=myhaffcode[k].start+1;s enstr=enstr+myhaffcode[k].bit[s]; } } } } 第6页 数据结构课程设计报告 for(t=0;t {cout< if(myhaffcode[k].value==temp[t]) { for(int s=myhaffcode[k].start+1;s cout<<\此字符串的编码为:\cout< cout<<\译码结果为:\ yima(myhafftree,j,enstr); cout< 测试数据运行结果: 第7页 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库数据结构课程设计报告 哈夫曼编码译码器(2)在线全文阅读。
相关推荐: