diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/TouGe-Huffman-Tree.iml b/.idea/TouGe-Huffman-Tree.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/TouGe-Huffman-Tree.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1861faa --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SY1.cpp b/SY1.cpp new file mode 100644 index 0000000..e1edbfb --- /dev/null +++ b/SY1.cpp @@ -0,0 +1,73 @@ +// /Users/zhangzhiqi/Library/Mobile Documents/M6HJR9W95L~com~textasticapp~textastic/Documents/CLionProjects/TouGe-Huffman-Tree/SY1.cpp +// Copyright (c) 2022. +// @Time : 2022/4/30 13:9:13 +// @Author : 张稚琦 +// @Address: 湖北理工学院腾龙公寓 5620 +// @Email : zhang@zhang.mba / zhangzhiqi828@gmail.com / zhangzhiqi@lh83.onmicrosoft.com / 2272358828@qq.com +// @File : SY1.cpp +// @LastModified: 2022/4/30 下午1:07 +// @ProjectName : TouGe_Huffman_Tree + +# include +# include +# include +using namespace std; + + +typedef struct //define structure HuffmanTree +{ int weight; + int parent,lchild,rchild; +}HTNode,*HuffmanTree; + +typedef char ** HuffmanCode; + +void Select(HuffmanTree HT,int i,int &s1,int &s2) ;//选出HT树到i为止,权值最小且parent为0的2个节点 +void HuffmanTreeing(HuffmanTree &HT,int *w,int n);//构建哈夫曼树函数 + +void output(HuffmanTree HT,int m);//输出哈夫曼树 + +int main() +{ + HuffmanTree HT; + HuffmanCode HC; + int n,i; + int *w; + scanf("%d",&n); + w=(int *)malloc(n*sizeof(int)); + for(i=0;i0),构造赫夫曼树HT + /********** Begin **********/ + + + /********** End **********/ +} + + +void output(HuffmanTree HT,int m) +{ //输出哈夫曼树 + for(int i=1;i<=m;++i) + { + cout<<"HT["<