資源簡介
初始化:給出十萬個隨機字符 字符中只包含小寫的英文字母a z 輸出初始化文件名為input txt 可以使用給出的隨機代碼自己隨機生成十萬個字符 代碼見附錄rand cpp 也可以使用給出的十萬個字符 文件見附錄input txt 2 建立編碼表:建立相應的huffman樹 對上述字符進行編碼 3 編碼:根據編碼表對輸入的字符串進行編碼壓縮 并將編碼后的字符串輸出到compress txt文件中 4 譯碼:對compress txt中的壓縮字符進行解壓縮 把解壓的答案輸出到文件decompress txt文件中 5 比較decompress txt和input txt中的字符是否完全相同 并計
代碼片段和文件信息
//?函數實現文件CourseDesign.cpp
#include“CourseDesign.h“
#include
#include
#include
#include
#include
using?namespace?std;
//-----------折半查找----------------
template
int?xj_Search_Bin(int?key?T?L?int?low?int?high)
{
??int?mid?=?0;
??int?internal_code;
??while?(low?<=?high)
??{
?????mid?=?(low?+?high)?/?2;
?????internal_code?=?int(L[mid].internal_code?&?0xFF);
?????if?(key?==?internal_code)
?????{
?????????return?mid;
?????}
?????else?if?(internal_code?>?key)
?????{
?????????high?=?mid?-?1;
?????}
?????else
?????{
?????????low?=?mid?+?1;
?????}
??}
??return?0;
}
//--------對HC表的字符域做插入非遞減排序-----
template
void?xj_Ins
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-12-11?16:55??Test\
?????目錄???????????0??2014-12-31?09:52??Test\bin\
?????目錄???????????0??2014-12-31?09:52??Test\bin\Debug\
?????文件???????11076??2014-12-31?09:27??Test\CourseDesign.cpp
?????文件????????1556??2014-12-31?09:47??Test\CourseDesign.h
?????文件????????1642??2014-12-31?09:49??Test\main.cpp
?????目錄???????????0??2014-12-31?09:52??Test\obj\
?????目錄???????????0??2014-12-31?09:52??Test\obj\Debug\
?????文件????????1123??2014-12-31?09:50??Test\Test.cbp
?????文件?????????347??2014-12-31?09:50??Test\Test.layout
?????文件???????????0??2018-12-11?16:55??Test\說明.txt
評論
共有 條評論