-
大小: 6KB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-10
- 語(yǔ)言: 其他
- 標(biāo)簽:
資源簡(jiǎn)介
Huffman
構(gòu)造自適應(yīng)霍夫曼樹(shù)實(shí)現(xiàn)文件的壓縮與解壓縮。-Adaptive Huffman tree structure for file compression and decompression.
文件列表(點(diǎn)擊判斷是否您需要的文件,如果是垃圾請(qǐng)?jiān)谙旅嬖u(píng)價(jià)投訴):
Encoder\Huffman.h
.......\Encoder.cpp
Decoder\Huffman.h
.......\Decoder.cpp
Encoder
Decoder
代碼片段和文件信息
#include?“Huffman.h“
int?main(int?argcchar*?argv[]){
????FILE*?outFile;
if((inFile=fopen(“Huff.a““rb“))==NULL){
printf(“Can‘t?open?file?to?read!\n“);
exit(0);
}
if((outFile=fopen(“Huff.java““wb“))==NULL){
printf(“can‘t?open?file?to?write!\n“);
exit(0);
}
????int?outLen=0;
int?c;
while((c=fgetc(inFile))!=EOF){
outLen++;
}
outLen-=1;
rewind(inFile);
????initNodeAddress();
/*對(duì)每一個(gè)接收到的字符,進(jìn)行編碼,并隨時(shí)更新樹(shù)*/
/*接受第一個(gè)字符*/
int?hc;
hc=fgetc(inFile);
if(hc==EOF)goto?EXIT;
/*設(shè)置根*/
root=zeroNode=createNode();
fputc((unsigned?char)hcoutFile);//輸出第一個(gè)字符
/*重新更新樹(shù)*/
updateTree(hc);
initInBuf();
/*讀更多的字符,主循環(huán)*/
while(outLen--){
????????hc=Decompress(root);
if(hc==ZERO_NODE){//忽視,取下一個(gè)字節(jié)
hc=get_nbits(8);
}
?????
?/*更新樹(shù)*/
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1301??2009-06-28?20:17??Encoder\Huffman.h
?????文件???????6805??2009-06-28?23:31??Encoder\Encoder.cpp
?????文件???????1274??2009-06-28?21:15??Decoder\Huffman.h
?????文件???????6076??2009-06-28?23:44??Decoder\Decoder.cpp
?????目錄??????????0??2009-06-28?23:27??Encoder
?????目錄??????????0??2009-06-28?23:35??Decoder
-----------?---------??----------?-----??----
????????????????15456????????????????????6
- 上一篇:msp430電子時(shí)鐘
- 下一篇:人月神話的讀書筆記
評(píng)論
共有 條評(píng)論