文章

17

粉丝

0

获赞

119

访问

4.5k

头像
哈夫曼编码 题解:
P1562
发布于2025年3月2日 13:38
阅读数 288

#include<bits/stdc++.h>
using namespace std;

int main(){
    char s[100];
    while(cin>>s){
        int a1,w;
        double a3;
        map<char,int> m;
        if (strcmp(s, "END") == 0) break;


        int len =strlen(s);
        a1=8*len;


        for(int i =0;i<len;i++) m[s[i]]++;


        priority_queue<int,vector<int>,greater<int>> pr;
        
        for (auto& entry : m) pr.push(entry.second);
        //for(int i =0;i<len;i++) pr.push(m[i]); 这样写错误 因为这里的i是 char,不能定义为int
        w=0;
    &...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发