小编The*_*ect的帖子

优先队列错误订单

我正在编写霍夫曼编码.这是我的计划的开始:

using namespace std;

//Counting methods
int *CountCharOccurence(string text)
{
    int *charOccurrence = new int[127];
    for(int i = 0; i < text.length(); i++)
    {
        charOccurrence[text[i]]++;
    }
    return charOccurrence;
}

void DisplayCharOccurence(int *charOccurrence)
{
    for(int i = 0; i < 127; i++)
    {
        if(charOccurrence[i] > 0)
        {
            cout << (char)i << ": " << charOccurrence[i] << endl;
        }
    }
}

//Node struct
struct Node
{
    public:
        char character;
        int occurrence;

        Node(char c, int occ) {
            character = c;
            occurrence = occ; …
Run Code Online (Sandbox Code Playgroud)

c++ priority-queue huffman-code

3
推荐指数
1
解决办法
1603
查看次数

标签 统计

c++ ×1

huffman-code ×1

priority-queue ×1