-
大小: 17KB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-01
- 語言: 其他
- 標(biāo)簽: 數(shù)據(jù)結(jié)構(gòu)??課程設(shè)計(jì)??南航??
資源簡介
任務(wù) :對一篇英文文章,統(tǒng)計(jì)各字符出現(xiàn)的次數(shù),實(shí)現(xiàn)Huffman編碼;
要求:輸出每個字符出現(xiàn)的次數(shù)和編碼,其中求最小權(quán)值要求用堆實(shí)現(xiàn);
注意:在Huffman編碼后,要將編碼表和英文文章編碼結(jié)果保存到文件中,并提供讀編碼文件生成原文件的功能。
代碼片段和文件信息
#include
#include
#include
#include
#include
#include
#define?MAX?30
#define?MAXWEIGHT??30000
typedef?struct{
int?key;
int?position;
}redtype?;
typedef?struct{
redtype?r[27];
int?length;
}sqlist;
typedef?struct{
char?data;
int?weight;
int?parent;
int?lchild;
int?rchild;
}huffnode*huffmantree;//赫夫曼結(jié)點(diǎn)
typedef?struct{
char?cd[MAX];
int?start;
}huffcode*huffmancode;//赫夫曼編碼
char?codefilenm[81];//翻譯后保存的文件名codefilenm
?????????????????????//此文件在編碼和譯碼時都有需要
huffmantree?ht;
??huffmancode?hc;
int?count[27];
int?leafnum=26;
?char?letter[28]={‘@‘‘a(chǎn)‘‘b‘‘c‘‘d‘‘e‘‘f‘‘g‘‘h‘‘i‘‘j‘‘k‘‘l‘
‘m‘‘n‘‘o‘‘p‘‘q‘‘r‘‘s‘‘t‘‘u‘‘v‘‘w‘‘x‘‘y‘‘z‘‘\0‘};//@鍵代表不是英文字符的其他數(shù)符;
?
//函數(shù)名:in
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2175??2008-01-11?19:51??赫夫曼編碼\input.txt
?????文件????????638??2008-01-09?13:22??赫夫曼編碼\mine.txt
?????文件????????638??2008-01-11?19:52??赫夫曼編碼\my.txt
?????文件?????112561??2008-01-11?19:56??赫夫曼編碼\哈夫曼編寫編譯碼.rtf
?????文件??????12374??2008-01-11?19:57??赫夫曼編碼\赫夫曼?.cpp
?????目錄??????????0??2013-01-24?16:21??赫夫曼編碼
-----------?---------??----------?-----??----
???????????????128386????????????????????6
評論
共有 條評論