init commit
This commit is contained in:
34
archive/algorithm/struct/tree/huffman.c
Normal file
34
archive/algorithm/struct/tree/huffman.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct hfm *HaffmanTree;
|
||||
|
||||
struct hfm
|
||||
{
|
||||
HaffmanTree node;
|
||||
int val;
|
||||
int priority;
|
||||
};
|
||||
|
||||
int hashQ[26]; //权
|
||||
HaffmanTree tree;
|
||||
//构建列表
|
||||
HaffmanTree buildList(char *str)
|
||||
{
|
||||
//先计算权
|
||||
for (int i = 0; i < strlen(str); i++)
|
||||
{
|
||||
hashQ[str[i] - 'a']++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
tree = malloc(hfm) char str[] = "athisteststring";
|
||||
|
||||
buildList(str);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user