91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 0.6M
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-27
  • 語言: 其他
  • 標簽: 其他??

資源簡介

哈夫曼編碼.zip

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
using?namespace?std;
#include
#include
#define?MaxSize?100
#define?MaxQueue?100
struct?linklist????????????????????????????????????????//單鏈表結點類型
{
char?data;
linklist?*next;
};
struct?pindu???????????????????????????????????????????//每個字母出現的頻度結點類型
{
char?data;?????????//字母???????????
int?weight;????????//權值
};
template?
struct?HTNode??????????????????????????????????????????//哈夫曼結點類型
{
T?data;//結點值
double?weight;//權值
int?parent;//雙親結點
int?lchild;//左孩子結點
int?rchild;//右孩子結點
};

struct?HCode???????????????????????????????????????????//哈夫曼編碼類型
{
char?cd[MaxSize];??????????????//存放當前結點的哈夫曼編碼
int?start;????????????????????//用cd[start..no]存放哈夫曼編碼包括start和no
};
class?sqlist
{
private:
linklist?*head;
int?Count;??????????????????????????//計算個數?
public:
pindu?aa[100];??????????????????????//存放頻度的信息
sqlist()
{
head?=?new?linklist[100];
head->next?=?NULL;
Count?=?0;
}
void?destorysqlist()?????????????????????//刪除單鏈表,不能用析構,因為隨時不用,會對哈夫曼數的構造造成影響
{
linklist?*pre?*p;
pre?=?head;
p?=?pre->next;
while?(p?!=?NULL)
{
delete?pre;
pre?=?p;?p?=?p->next;
}
delete?pre;
}
int?getCount()???????????????????????//得到權值個數
{
linklist?*s;
int?j?=?0;
int?count[127]?=?{?0?};?????????????//設置初始化
s?=?head->next;
int?num;
while?(s)
{
num?=?s->data;
if?(num?!=?32)???????????????//不計算空格出現的頻度
{
count[num?-?0]++;
}
s?=?s->next;
}
for?(int?i?=?0;?i? {
if?(count[i])
{
aa[j].data?=?i;
aa[j].weight?=?count[i];
j++;
}
}
Count?=?j;
return?Count;
}
void?creatlist()?????????????????????//創建單鏈表,把文件中的字母寫進單鏈表中
{
linklist?*s?*r;
r?=?head;
FILE?*fin;
char?ch;
/*char?filename[100]?=?{?0?};
cout?< cin?>>?filename;*/
if?((fin?=?fopen(“H:\\test.txt“?“r“))?==?NULL)
{
cout?< exit(0);
}
ch?=?fgetc(fin);
while?(!feof(fin))
{
s?=?new?linklist;
s->data?=?ch;
r->next?=?s;
r?=?s;
ch?=?fgetc(fin);??//從fin?文件中打開
}
r->next?=?NULL;
fclose(fin);
/* cout?< cout?< }
void?disp()?????????????????????????????????//輸出單鏈表內容,即文章內容
{
cout?< linklist?*s;
s?=?head->next;
int?count[257]?=?{?0?};
while?(s)
{
cout?<data;
s?=?s->next;
}
cout?< }
void?total()???????????????????????????//利用一個數組,統計字母出現次數
{
linklist?*s;
int?j?=?0;
int?count[127]?=?{?0?};?????????????//設置初始化
s?=?head->next;
int?num;
while?(s)
{
num?=?s->data;
if?(num?!=?32)???????????????//不計算空格出現的頻度
{
count[num?-?0]++;
}
s?=?s->next;
}
cout?< cout?< cout?<

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-12-23?09:00??哈夫曼編碼\
?????文件???????12257??2016-12-23?08:49??哈夫曼編碼\Haffuman.cpp
?????文件?????1934225??2016-12-23?08:49??哈夫曼編碼\Haffuman.exe
?????目錄???????????0??2016-12-23?08:36??哈夫曼編碼\三個要創建的txt實例\
?????文件??????????21??2016-12-23?07:52??哈夫曼編碼\三個要創建的txt實例\test.txt
?????文件??????????12??2016-12-23?08:22??哈夫曼編碼\三個要創建的txt實例\test1.txt
?????文件??????????46??2016-12-23?08:34??哈夫曼編碼\三個要創建的txt實例\tex.txt
?????文件?????????706??2016-12-23?08:50??哈夫曼編碼\先讀.txt
?????文件??????189212??2015-12-31?13:20??哈夫曼編碼\實驗報告.docx

評論

共有 條評論