{"id":4015,"date":"2019-12-16T07:40:03","date_gmt":"2019-12-15T23:40:03","guid":{"rendered":"https:\/\/damogame.cn\/wordpress\/?p=4015"},"modified":"2019-12-16T07:40:03","modified_gmt":"2019-12-15T23:40:03","slug":"%e5%93%88%e5%a4%ab%e6%9b%bc%e7%bc%96%e7%a0%81%e5%8e%9f%e7%90%86%e8%af%a6%e8%a7%a3%e5%8f%8a%e5%ba%94%e7%94%a8%e5%ae%9e%e4%be%8b%e5%93%88%e5%a4%ab%e6%9b%bc%e7%bc%96%e7%a0%81%e7%ae%97%e6%b3%95%e6%b5%81","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/4015","title":{"rendered":"\u54c8\u592b\u66fc\u7f16\u7801\u539f\u7406\u8be6\u89e3\u53ca\u5e94\u7528\u5b9e\u4f8b,\u54c8\u592b\u66fc\u7f16\u7801\u7b97\u6cd5\u6d41\u7a0b\u56fe &#8211; \u5168\u6587"},"content":{"rendered":"<p class=\"article-title\"><a href=\"http:\/\/www.elecfans.com\/emb\/600117_a.html\">\u539f\u6587\u5730\u5740<\/a><\/p>\n<p>&nbsp;<\/p>\n<article class=\"amain\">\n<div class=\"main-wrap\">\n<div class=\"article-content simditor clearfix\">\n<div class=\"simditor-body clearfix\">\n<p>\u3000\u3000\u6458\u8981\uff1a\u4f5c\u4e3a\u4e00\u79cd\u5e38\u7528\u7684\u7f16\u7801\u65b9\u5f0f\u5373\u54c8\u592b\u66fc\u7f16\u7801\uff0c\u5f88\u591a\u4eba\u5728\u5b83\u7684\u539f\u7406\u5373\u5e94\u7528\u65b9\u9762\u90fd\u5f04\u4e0d\u4e0d\u6e05\u695a\uff0c\u672c\u6587\u4e3b\u8981\u4ee5\u54c8\u592b\u66fc\u7f16\u7801\u539f\u7406\u4e0e\u5e94\u7528\u5b9e\u4f8b\u53ca\u7b97\u6cd5\u6d41\u7a0b\u56fe\u4fe9\u8fdb\u4e00\u6b65\u8bf4\u660e\u3002<\/p>\n<h2><strong>\u3000\u3000\u54c8\u592b\u66fc\u7f16\u7801\u5b9a\u4e49<\/strong><\/h2>\n<p>\u54c8\u592b\u66fc\u7f16\u7801\uff08Huffman Coding\uff09\uff0c\u53c8\u79f0\u970d\u592b\u66fc\u7f16\u7801\uff0c\u662f\u4e00\u79cd\u7f16\u7801\u65b9\u5f0f\uff0c\u54c8\u592b\u66fc\u7f16\u7801\u662f\u53ef\u53d8\u5b57\u957f\u7f16\u7801\uff08VLC\uff09\u7684\u4e00\u79cd\u3002Huffman\u4e8e1952\u5e74\u63d0\u51fa\u4e00\u79cd\u7f16\u7801\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u5b8c\u5168\u4f9d\u636e\u5b57\u7b26\u51fa\u73b0\u6982\u7387\u6765\u6784\u9020\u5f02\u5b57\u5934\u7684\u5e73\u5747\u957f\u5ea6\u6700\u77ed\u7684\u7801\u5b57\uff0c\u6709\u65f6\u79f0\u4e4b\u4e3a\u6700\u4f73\u7f16\u7801\uff0c\u4e00\u822c\u5c31\u53eb\u505aHuffman\u7f16\u7801\uff08\u6709\u65f6\u4e5f\u79f0\u4e3a\u970d\u592b\u66fc\u7f16\u7801\uff09\u3002<\/p>\n<div id=\"new-middle-berry\"><\/div>\n<h2><strong>\u3000\u3000\u54c8\u592b\u66fc\u7f16\u7801\u539f\u7406<\/strong><\/h2>\n<div><a href=\"http:\/\/www.elecfans.com\/uploads\/allimg\/171211\/2755780-1G2110912525Q.jpg\" rel=\"lightbox-img\"><img decoding=\"async\" src=\"http:\/\/www.elecfans.com\/uploads\/allimg\/171211\/2755780-1G2110912525Q.jpg\" alt=\"\u54c8\u592b\u66fc\u7f16\u7801\u539f\u7406\u8be6\u89e3\u53ca\u5e94\u7528\u5b9e\u4f8b,\u54c8\u592b\u66fc\u7f16\u7801\u7b97\u6cd5\u6d41\u7a0b\u56fe\" \/><\/a><\/div>\n<p>\u8bbe\u67d0\u4fe1\u6e90\u4ea7\u751f\u6709\u4e94\u79cd\u7b26\u53f7u1\u3001u2\u3001u3\u3001u4\u548cu5\uff0c\u5bf9\u5e94\u6982\u7387P1=0.4\uff0cP2=0.1\uff0cP3=P4=0.2\uff0cP5=0.1\u3002\u9996\u5148\uff0c\u5c06\u7b26\u53f7\u6309\u7167\u6982\u7387\u7531\u5927\u5230\u5c0f\u6392\u961f\uff0c\u5982\u56fe\u6240\u793a\u3002\u7f16\u7801\u65f6\uff0c\u4ece\u6700\u5c0f\u6982\u7387\u7684\u4e24\u4e2a\u7b26\u53f7\u5f00\u59cb\uff0c\u53ef\u9009\u5176\u4e2d\u4e00\u4e2a\u652f\u8def\u4e3a0\uff0c\u53e6\u4e00\u652f\u8def\u4e3a1\u3002\u8fd9\u91cc\uff0c\u6211\u4eec\u9009\u4e0a\u652f\u8def\u4e3a0\uff0c\u4e0b\u652f\u8def\u4e3a1\u3002\u518d\u5c06\u5df2\u7f16\u7801\u7684\u4e24\u652f\u8def\u7684\u6982\u7387\u5408\u5e76\uff0c\u5e76\u91cd\u65b0\u6392\u961f\u3002\u591a\u6b21\u91cd\u590d\u4f7f\u7528\u4e0a\u8ff0\u65b9\u6cd5\u76f4\u81f3\u5408\u5e76\u6982\u7387\u5f52\u4e00\u65f6\u4e3a\u6b62\u3002\u4ece\u56fe\uff08a\uff09\u548c\uff08b\uff09\u53ef\u4ee5\u770b\u51fa\uff0c\u4e24\u8005\u867d\u5e73\u5747\u7801\u957f\u76f8\u7b49\uff0c\u4f46\u540c\u4e00\u7b26\u53f7\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u7801\u957f\uff0c\u5373\u7f16\u7801\u65b9\u6cd5\u5e76\u4e0d\u552f\u4e00\uff0c\u5176\u539f\u56e0\u662f\u4e24\u652f\u8def\u6982\u7387\u5408\u5e76\u540e\u91cd\u65b0\u6392\u961f\u65f6\uff0c\u53ef\u80fd\u51fa\u73b0\u51e0\u4e2a\u652f\u8def\u6982\u7387\u76f8\u7b49\uff0c\u9020\u6210\u6392\u961f\u65b9\u6cd5\u4e0d\u552f\u4e00\u3002\u4e00\u822c\uff0c\u82e5\u5c06\u65b0\u5408\u5e76\u540e\u7684\u652f\u8def\u6392\u5230\u7b49\u6982\u7387\u7684\u6700\u4e0a\u652f\u8def\uff0c\u5c06\u6709\u5229\u4e8e\u7f29\u77ed\u7801\u957f\u65b9\u5dee\uff0c\u4e14\u7f16\u51fa\u7684\u7801\u66f4\u63a5\u8fd1\u4e8e\u7b49\u957f\u7801\u3002\u8fd9\u91cc\u56fe\uff08a\uff09\u7684\u7f16\u7801\u6bd4\uff08b\uff09\u597d\u3002<\/p>\n<p>\u8d6b\u592b\u66fc\u7801\u7684\u7801\u5b57\uff08\u5404\u7b26\u53f7\u7684\u4ee3\u7801\uff09\u662f\u5f02\u524d\u7f6e\u7801\u5b57\uff0c\u5373\u4efb\u4e00\u7801\u5b57\u4e0d\u4f1a\u662f\u53e6\u4e00\u7801\u5b57\u7684\u524d\u9762\u90e8\u5206\uff0c\u8fd9\u4f7f\u5404\u7801\u5b57\u53ef\u4ee5\u8fde\u5728\u4e00\u8d77\u4f20\u9001\uff0c\u4e2d\u95f4\u4e0d\u9700\u53e6\u52a0\u9694\u79bb\u7b26\u53f7\uff0c\u53ea\u8981\u4f20\u9001\u65f6\u4e0d\u51fa\u9519\uff0c\u6536\u7aef\u4ecd\u53ef\u5206\u79bb\u5404\u4e2a\u7801\u5b57\uff0c\u4e0d\u81f4\u6df7\u6dc6\u3002<\/p>\n<p>\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u9664\u91c7\u7528\u5b9a\u65f6\u6e05\u6d17\u4ee5\u6d88\u9664\u8bef\u5dee\u6269\u6563\u548c\u91c7\u7528\u7f13\u51b2\u5b58\u50a8\u4ee5\u89e3\u51b3\u901f\u7387\u5339\u914d\u4ee5\u5916\uff0c\u4e3b\u8981\u95ee\u9898\u662f\u89e3\u51b3\u5c0f\u7b26\u53f7\u96c6\u5408\u7684\u7edf\u8ba1\u5339\u914d\uff0c\u4f8b\u5982\u9ed1\uff081\uff09\u3001\u767d\uff080\uff09\u4f20\u771f\u4fe1\u6e90\u7684\u7edf\u8ba1\u5339\u914d\uff0c\u91c7\u75280\u548c1\u4e0d\u540c\u957f\u5ea6\u6e38\u7a0b\u7ec4\u6210\u6269\u5927\u7684\u7b26\u53f7\u96c6\u5408\u4fe1\u6e90\u3002\u6e38\u7a0b\uff0c\u6307\u76f8\u540c\u7801\u5143\u7684\u957f\u5ea6\uff08\u5982\u4e8c\u8fdb\u7801\u4e2d\u8fde\u7eed\u7684\u4e00\u4e320\u6216\u4e00\u4e321\u7684\u957f\u5ea6\u6216\u4e2a\u6570\uff09\u3002\u6309\u7167CCITT\u6807\u51c6\uff0c\u9700\u8981\u7edf\u8ba12&amp;<u><\/u><u><a class=\"blue\" title=\"TI\u793e\u533a\" href=\"http:\/\/bbs.elecfans.com\/zhuti_715_1.html\" target=\"_blank\" rel=\"noopener noreferrer\">TI<\/a><\/u>mes;1728\u79cd\u6e38\u7a0b\uff08\u957f\u5ea6\uff09\uff0c\u8fd9\u6837\uff0c\u5b9e\u73b0\u65f6\u7684\u5b58\u50a8\u91cf\u592a\u5927\u3002\u4e8b\u5b9e\u4e0a\u957f\u6e38\u7a0b\u7684\u6982\u7387\u5f88\u5c0f\uff0c\u6545CCITT\u8fd8\u89c4\u5b9a\uff1a\u82e5l\u8868\u793a\u6e38\u7a0b\u957f\u5ea6\uff0c\u5219l=64q+r\u3002\u5176\u4e2dq\u79f0\u4e3b\u7801\uff0cr\u4e3a\u57fa\u7801\u3002\u7f16\u7801\u65f6\uff0c\u4e0d\u5c0f\u4e8e64\u7684\u6e38\u7a0b\u957f\u5ea6\u7531\u4e3b\u7801\u548c\u57fa\u7801\u7ec4\u6210\u3002\u800c\u5f53l\u4e3a64\u7684\u6574\u6570\u500d\u65f6\uff0c\u53ea\u7528\u4e3b\u7801\u7684\u4ee3\u7801\uff0c\u5df2\u4e0d\u5b58\u5728\u57fa\u7801\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u957f\u6e38\u7a0b\u7684\u4e3b\u7801\u548c\u57fa\u7801\u5747\u7528\u8d6b\u592b\u66fc\u89c4\u5219\u8fdb\u884c\u7f16\u7801\uff0c\u8fd9\u79f0\u4e3a\u4fee\u6b63\u8d6b\u592b\u66fc\u7801\uff0c\u5176\u7ed3\u679c\u6709\u8868\u53ef\u67e5\u3002\u8be5\u65b9\u6cd5\u5df2\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6587\u4ef6\u4f20\u771f\u673a\u4e2d\u3002<\/p>\n<h2><strong>\u3000\u3000\u54c8\u592b\u66fc\u7f16\u7801\u7b97\u6cd5\u6d41\u7a0b\u56fe<\/strong><\/h2>\n<p>\u54c8\u592b\u66fc\u7f16\u7801\u7684\u7b97\u6cd5\u662f\u67e5\u627e\u6700\u4f18\u8def\u5f84\u7684\u4e00\u79cd\u7b97\u6cd5\uff0c\u9996\u5148\u5728\u6240\u6709\u672a\u5206\u914dparent\u57df\u7684\u8282\u70b9\u4e2d\u627e\u51fa\u6700\u5c0f\u7684\u4e24\u4e2a\u8282\u70b9\uff0c\u5c06\u4ed6\u4eec\u7684\u5168\u503c\u76f8\u52a0\uff0c\u7ec4\u6210\u65b0\u7684\u8282\u70b9\uff0c\u5e76\u4e14\u5c06\u5b83\u6807\u8bb0\u4e3a\u539f\u6765\u4e24\u4e2a\u6700\u5c0f\u8282\u70b9\u7684parent\u3002\u8fd9\u6837\u8c03\u7528\u9012\u5f52\uff0c\u6700\u540e\u5c31\u80fd\u591f\u6210\u4e00\u9897\u5b8c\u6574\u7684\u54c8\u592b\u66fc\u6811\u3002\u7136\u540e\u5bf9 \u6bcf\u4e2a\u8282\u70b9\u8fdb\u884c\u904d\u5386\u7f16\u7801\uff0c\u5f97\u5230\u6700\u7ec8\u7684\u54c8\u592b\u66fc\u7f16\u7801\u5e93\u3002\u6d41\u7a0b\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><a href=\"http:\/\/www.elecfans.com\/uploads\/allimg\/171211\/2755780-1G211091113352.jpg\" rel=\"lightbox-img\"><img decoding=\"async\" src=\"http:\/\/www.elecfans.com\/uploads\/allimg\/171211\/2755780-1G211091113352.jpg\" alt=\"\u54c8\u592b\u66fc\u7f16\u7801\u539f\u7406\u8be6\u89e3\u53ca\u5e94\u7528\u5b9e\u4f8b,\u54c8\u592b\u66fc\u7f16\u7801\u7b97\u6cd5\u6d41\u7a0b\u56fe\" \/><\/a><\/p>\n<h2><strong>\u3000\u3000\u57fa\u4e8e\u54c8\u592b\u66fc\u7f16\u7801\u539f\u7406\u7684\u538b\u7f29\u7b97\u6cd5<\/strong><\/h2>\n<p>\u54c8\u592b\u66fc\u7b97\u6cd5\u7684\u8fc7\u7a0b\u4e3a\uff1a\u7edf\u8ba1\u539f\u59cb\u6570\u636e\u4e2d\u5404\u5b57\u7b26\u51fa\u73b0\u7684\u9891\u7387\uff1b\u6240\u6709\u5b57\u7b26\u6309\u9891\u7387\u964d\u5e8f\u6392\u5217\uff1b\u5efa\u7acb\u54c8\u592b\u66fc\u6811\uff1a\u5c06\u54c8\u592b\u66fc\u6811\u5b58\u5165\u7ed3\u679c\u6570\u636e\uff1b\u91cd\u65b0\u7f16\u7801\u539f\u59cb\u6570\u636e\u5230\u7ed3\u679c\u6570\u636e\u3002\u54c8\u592b\u66fc\u7b97\u6cd5\u5b9e\u73b0\u6d41\u7a0b\u5982\u56fe3\u6240\u793a\u3002<\/p>\n<p><a href=\"http:\/\/www.elecfans.com\/uploads\/allimg\/171211\/2755780-1G21109112X52.jpg\" rel=\"lightbox-img\"><img decoding=\"async\" src=\"http:\/\/www.elecfans.com\/uploads\/allimg\/171211\/2755780-1G21109112X52.jpg\" alt=\"\u54c8\u592b\u66fc\u7f16\u7801\u539f\u7406\u8be6\u89e3\u53ca\u5e94\u7528\u5b9e\u4f8b,\u54c8\u592b\u66fc\u7f16\u7801\u7b97\u6cd5\u6d41\u7a0b\u56fe\" \/><\/a><\/p>\n<p>\u54c8\u592b\u66fc\u7b97\u6cd5\u7684\u5b9e\u8d28\u662f\u9488\u5bf9\u7edf\u8ba1\u7ed3\u679c\u5bf9\u5b57\u7b26\u672c\u8eab\u91cd\u65b0\u7f16\u7801\uff0c\u800c\u4e0d\u662f\u5bf9\u91cd\u590d\u5b57\u7b26\u6216\u91cd\u590d\u5b50\u4e32\u7f16\u7801\u3002\u5b9e\u7528\u4e2d\uff0e\u7b26\u53f7\u7684\u51fa\u73b0\u9891\u7387\u4e0d\u80fd\u9884\u77e5\uff0c\u9700\u8981\u7edf\u8ba1\u548c\u7f16\u7801\u4e24\u6b21\u5904\u7406\uff0c\u6240\u4ee5\u901f\u5ea6\u8f83\u6162\uff0c\u65e0\u6cd5\u5b9e\u7528\u3002\u800c\u81ea\u9002\u5e94\uff08\u6216\u52a8\u6001\uff09\u54c8\u592b\u66fc\u7b97\u6cd5\u53d6\u6d88\u4e86\u7edf\u8ba1\uff0c\u53ef\u5728\u538b\u7f29\u6570\u636e\u65f6\u52a8\u6001\u8c03\u6574\u54c8\u592b\u66fc\u6811\uff0c\u8fd9\u6837\u53ef\u63d0\u9ad8\u901f\u5ea6\u3002\u56e0\u6b64\uff0c\u54c8\u592b\u66fc\u7f16\u7801\u6548\u7387\u9ad8\uff0c\u8fd0\u7b97\u901f\u5ea6\u5feb\uff0c\u5b9e\u73b0\u65b9\u5f0f\u7075\u6d3b\u3002<\/p>\n<p>\u91c7\u7528\u54c8\u592b\u66fc\u7f16\u7801\u65f6\u9700\u6ce8\u610f\u7684\u95ee\u9898\uff1a<\/p>\n<p>\uff081\uff09\u54c8\u592b\u66fc\u7801\u65e0\u9519\u8bef\u4fdd\u62a4\u529f\u80fd\uff0c\u8bd1\u7801\u65f6\uff0c\u7801\u4e32\u82e5\u65e0\u9519\u5c31\u80fd\u6b63\u786e\u8bd1\u7801\uff1b\u82e5\u7801\u4e32\u6709\u9519\u5e94\u8003\u8651\u589e\u52a0\u7f16\u7801\uff0c\u63d0\u9ad8\u53ef\u9760\u6027\u3002<\/p>\n<p>\uff082\uff09\u54c8\u592b\u66fc\u7801\u662f\u53ef\u53d8\u957f\u5ea6\u7801\uff0c\u56e0\u6b64\u5f88\u96be\u968f\u610f\u67e5\u627e\u6216\u8c03\u7528\u538b\u7f29\u6587\u4ef6\u4e2d\u95f4\u7684\u5185\u5bb9\uff0c\u7136\u540e\u518d\u8bd1\u7801\uff0c\u8fd9\u5c31\u9700\u8981\u5728\u5b58\u50a8\u4ee3\u7801\u4e4b\u524d\u52a0\u4ee5\u8003\u8651\u3002<\/p>\n<p>\uff083\uff09\u54c8\u592b\u66fc\u6811\u7684\u5b9e\u73b0\u548c\u66f4\u65b0\u65b9\u6cd5\u5bf9\u8bbe\u8ba1\u975e\u5e38\u5173\u952e\u3002<\/p>\n<h2><strong>\u3000\u3000\u54c8\u592b\u66fc\u7f16\u7801\u5e94\u7528\u5b9e\u4f8b<\/strong><\/h2>\n<p>\u54c8\u592b\u66fc\u7f16\u7801\uff0c\u4e3b\u8981\u7528\u9014\u662f\u5b9e\u73b0\u6570\u636e\u538b\u7f29\u3002<\/p>\n<p>\u8bbe\u7ed9\u51fa\u4e00\u6bb5\u62a5\u6587\uff1aCAST CAST SAT AT A TASA\u3002\u5b57\u7b26\u96c6\u5408\u662f { C\uff0c A\uff0c S\uff0c T }\uff0c\u5404\u4e2a\u5b57\u7b26\u51fa\u73b0\u7684\u9891\u5ea6\uff08\u6b21\u6570\uff09\u662f W\uff1d{ 2\uff0c 7\uff0c 4\uff0c 5 }\u3002\u82e5\u7ed9\u6bcf\u4e2a\u5b57\u7b26\u4ee5\u7b49\u957f\u7f16\u7801A \uff1a 00 T \uff1a 10 C \uff1a 01 S \uff1a 11\uff0c\u5219\u603b\u7f16\u7801\u957f\u5ea6\u4e3a \uff08 2+7+4+5 \uff09 * 2 = 36\u3002<\/p>\n<p>\u82e5\u6309\u5404\u4e2a\u5b57\u7b26\u51fa\u73b0\u7684\u6982\u7387\u4e0d\u540c\u800c\u7ed9\u4e88\u4e0d\u7b49\u957f\u7f16\u7801\uff0c\u53ef\u671b\u51cf\u5c11\u603b\u7f16\u7801\u957f\u5ea6\u3002\u5404\u5b57\u7b26\u51fa\u73b0\u6982\u7387\u4e3a{ 2\/18\uff0c 7\/18\uff0c 4\/18\uff0c 5\/18 }\uff0c\u5316\u6574\u4e3a { 2\uff0c 7\uff0c 4\uff0c 5 }\u3002\u4ee5\u5b83\u4eec\u4e3a\u5404\u53f6\u7ed3\u70b9\u4e0a\u7684\u6743\u503c\uff0c \u5efa\u7acb\u970d\u592b\u66fc\u6811\u3002\u5de6\u5206\u652f\u8d4b 0\uff0c\u53f3\u5206\u652f\u8d4b 1\uff0c\u5f97\u970d\u592b\u66fc\u7f16\u7801\uff08\u53d8\u957f\u7f16\u7801\uff09\u3002A \uff1a 0 T \uff1a 10 C \uff1a 110 S \uff1a 111\u3002\u5b83\u7684\u603b\u7f16\u7801\u957f\u5ea6\uff1a7*1+5*2+\uff08 2+4 \uff09*3 = 35\u3002\u6bd4\u7b49\u957f\u7f16\u7801\u7684\u60c5\u5f62\u8981\u77ed\u3002\u970d\u592b\u66fc\u7f16\u7801\u662f\u4e00\u79cd\u65e0\u524d\u7f00\u7f16\u7801\u3002\u89e3\u7801\u65f6\u4e0d\u4f1a\u6df7\u6dc6\u3002\u5e26\u6743\u8def\u5f84\u957f\u5ea6\u8fbe\u5230\u6700\u5c0f\u7684\u4e8c\u53c9\u6811\u5373\u4e3a\u970d\u592b\u66fc\u6811\u3002\u5728\u970d\u592b\u66fc\u6811\u4e2d\uff0c\u6743\u503c\u5927\u7684\u7ed3\u70b9\u79bb\u6839\u6700\u8fd1\u3002<\/p>\n<p>\u970d\u592b\u66fc\u7b97\u6cd5<\/p>\n<p>1.\u7531\u7ed9\u5b9a\u7684 n \u4e2a\u6743\u503c {w0\uff0c w1\uff0c w2\uff0c \u2026\uff0c wn-1}\uff0c\u6784\u9020\u5177\u6709 n \u68f5\u6269\u5145\u4e8c\u53c9\u6811\u7684\u68ee\u6797 F = { T0\uff0c T1\uff0c T2\uff0c \u2026\uff0c Tn-1 }\uff0c\u5176\u4e2d\u6bcf\u68f5\u6269\u5145\u4e8c\u53c9\u6811\u00a0<a class=\"blue\" title=\"TI\u793e\u533a\" href=\"http:\/\/bbs.elecfans.com\/zhuti_715_1.html\" target=\"_blank\" rel=\"noopener noreferrer\">TI<\/a>\u00a0\u53ea\u6709\u4e00 \u4e2a\u5e26\u6743\u503c wi \u7684\u6839\u7ed3\u70b9\uff0c \u5176\u5de6\u3001\u53f3\u5b50\u6811\u5747\u4e3a\u7a7a\u3002<\/p>\n<p>2.\u91cd\u590d\u4ee5\u4e0b\u6b65\u9aa4\uff0c \u76f4\u5230 F \u4e2d\u4ec5\u5269\u4e0b\u4e00\u68f5\u6811\u4e3a\u6b62\uff1a<\/p>\n<p>\u2460 \u5728 F \u4e2d\u9009\u53d6\u4e24\u68f5\u6839\u7ed3\u70b9\u7684\u6743\u503c\u6700\u5c0f\u7684\u6269\u5145\u4e8c\u53c9\u6811\uff0c\u505a\u4e3a\u5de6\u3001\u53f3\u5b50\u6811\u6784\u9020\u4e00\u68f5\u65b0\u7684\u4e8c\u53c9\u6811\u3002\u7f6e\u65b0\u7684\u4e8c\u53c9\u6811\u7684\u6839\u7ed3\u70b9\u7684\u6743\u503c\u4e3a\u5176\u5de6\u3001\u53f3\u5b50\u6811\u4e0a\u6839\u7ed3\u70b9\u7684\u6743\u503c\u4e4b\u548c\u3002<\/p>\n<p>\u2461 \u5728 F \u4e2d\u5220\u53bb\u8fd9\u4e24\u68f5\u4e8c\u53c9\u6811\u3002<\/p>\n<p>\u2462 \u628a\u65b0\u7684\u4e8c\u53c9\u6811\u52a0\u5165 F\u3002<\/p>\n<p>#include \u300astdio.h\u300b<\/p>\n<p>#include \u300astdlib.h\u300b<\/p>\n<p>#include \u300astring.h\u300b<\/p>\n<p>#define MAX 32767<\/p>\n<p>typedef char *HuffmanCode;<\/p>\n<p>typedef struct<\/p>\n<p>{<\/p>\n<p>int Weight;\/\/\u5b57\u6bcd\u7684\u6743<\/p>\n<p>int Parent\uff0cLeftchild\uff0cRightchild;<\/p>\n<p>}HuffmanTree;<\/p>\n<p>void Select\uff08HuffmanTree *HT\uff0cint n\uff0cint *s1\uff0cint *s2\uff09<\/p>\n<p>{<\/p>\n<p>int min1=MAX;<\/p>\n<p>int min2=MAX;<\/p>\n<p>int pos1\uff0c pos2;<\/p>\n<p>int i;<\/p>\n<p>for\uff08i=0;i\u300an;i++\uff09<\/p>\n<p>{<\/p>\n<p>if\uff08HT\uff3bi\uff3d.Parent==-1\uff09\/\/\u9009\u62e9\u8fd8\u6ca1\u6709\u7236\u4eb2\u7684\u8282\u70b9<\/p>\n<p>{<\/p>\n<p>if\uff08HT\uff3bi\uff3d.Weight\u300a=min1\uff09<\/p>\n<p>{<\/p>\n<p>pos2 = pos1; min2 = min1;<\/p>\n<p>pos1 = i; min1=HT\uff3bi\uff3d.Weight;<\/p>\n<p>}<\/p>\n<p>else if\uff08HT\uff3bi\uff3d.Weight\u300a=min2\uff09<\/p>\n<p>{<\/p>\n<p>pos2 = i; min2=HT\uff3bi\uff3d.Weight;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>*s1=pos1;*s2=pos2;<\/p>\n<p>}<\/p>\n<p>void Crea<a href=\"http:\/\/www.elecfans.com\/tags\/te\/\" target=\"_blank\" rel=\"noopener noreferrer\"><u>te<\/u><\/a>Tree\uff08HuffmanTree *HT\uff0cint n\uff0cint *w\uff09<\/p>\n<p>{<\/p>\n<p>int m=2*n-1;\/\/\u603b\u7684\u8282\u70b9\u6570<\/p>\n<p>int s1\uff0cs2;<\/p>\n<p>int i;<\/p>\n<p>for\uff08i=0;i\u300am;i++\uff09<\/p>\n<p>{<\/p>\n<p>if\uff08i\u300an\uff09<\/p>\n<p>HT\uff3bi\uff3d.Weight=w\uff3bi\uff3d;<\/p>\n<p>else<\/p>\n<p>HT\uff3bi\uff3d.Weight=-1;<\/p>\n<p>HT\uff3bi\uff3d.Parent=-1;<\/p>\n<p>HT\uff3bi\uff3d.Leftchild=-1;<\/p>\n<p>HT\uff3bi\uff3d.Rightchild=-1;<\/p>\n<p>}<\/p>\n<p>for\uff08i=n;i\u300am;i++\uff09<\/p>\n<p>{<\/p>\n<p>Select\uff08HT\uff0ci\uff0c&amp;s1\uff0c&amp;s2\uff09;\/\/\u8fd9\u4e2a\u51fd\u6570\u662f\u4ece0\u5230n-1\u4e2d\u9009\u4e24\u4e2a\u6743\u6700\u5c0f\u7684\u8282\u70b9<\/p>\n<p>HT\uff3bi\uff3d.Weight=HT\uff3bs1\uff3d.Weight+HT\uff3bs2\uff3d.Weight;<\/p>\n<p>HT\uff3bi\uff3d.Leftchild=s1;<\/p>\n<p>HT\uff3bi\uff3d.Rightchild=s2;<\/p>\n<p>HT\uff3bs1\uff3d.Parent=i;<\/p>\n<p>HT\uff3bs2\uff3d.Parent=i;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>void Print\uff08HuffmanTree *HT\uff0cint m\uff09<\/p>\n<p>{<\/p>\n<p>if\uff08m\uff01=-1\uff09<\/p>\n<p>{<\/p>\n<p>printf\uff08\u201c%d \u201d\uff0cHT\uff3bm\uff3d.Weight\uff09;<\/p>\n<p>Print\uff08HT\uff0cHT\uff3bm\uff3d.Leftchild\uff09;<\/p>\n<p>Print\uff08HT\uff0cHT\uff3bm\uff3d.Rightchild\uff09;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>void Huffmancoding\uff08HuffmanTree *HT\uff0cint n\uff0cHuffmanCode *hc\uff0cchar *lette<a href=\"http:\/\/www.elecfans.com\/tags\/rs\/\" target=\"_blank\" rel=\"noopener noreferrer\"><u>rs<\/u><\/a>\uff09<\/p>\n<p>{<\/p>\n<p>char *cd;<\/p>\n<p>int start;<\/p>\n<p>int Current\uff0cparent;<\/p>\n<p>int i;<\/p>\n<p>cd=\uff08char*\uff09malloc\uff08sizeof\uff08char\uff09*n\uff09;\/\/\u7528\u6765\u4e34\u65f6\u5b58\u653e\u4e00\u4e2a\u5b57\u6bcd\u7684\u7f16\u7801\u7ed3\u679c<\/p>\n<p>cd\uff3bn-1\uff3d=\u2018\\0\u2019;<\/p>\n<p>for\uff08i=0;i\u300an;i++\uff09<\/p>\n<p>{<\/p>\n<p>start=n-1;<\/p>\n<p>for\uff08Current=i\uff0cparent=HT\uff3bCurrent\uff3d.Parent; parent\uff01=-1; Current=parent\uff0cparent=HT\uff3bparent\uff3d.Parent\uff09<\/p>\n<p>if\uff08Current==HT\uff3bparent\uff3d.Leftchild\uff09\/\/\u5224\u65ad\u8be5\u8282\u70b9\u662f\u7236\u8282\u70b9\u7684\u5de6\u5b69\u5b50\u8fd8\u662f\u53f3\u5b69\u5b50<\/p>\n<p>cd\uff3b&#8211;start\uff3d=\u20180\u2019;<\/p>\n<p>else<\/p>\n<p>cd\uff3b&#8211;start\uff3d=\u20181\u2019;<\/p>\n<p>hc\uff3bi\uff3d=\uff08char*\uff09malloc\uff08sizeof\uff08char\uff09*\uff08n-start\uff09\uff09;<\/p>\n<p>strcpy\uff08hc\uff3bi\uff3d\uff0c&amp;cd\uff3bstart\uff3d\uff09;<\/p>\n<p>}<\/p>\n<p>free\uff08cd\uff09;<\/p>\n<p>for\uff08i=0;i\u300an;i++\uff09<\/p>\n<p>{<\/p>\n<p>printf\uff08\u201cletters\uff1a%c\uff0cweight\uff1a%d\uff0c\u7f16\u7801\u4e3a %s\\n\u201d\uff0cletters\uff3bi\uff3d\uff0cHT\uff3bi\uff3d.Weight\uff0chc\uff3bi\uff3d\uff09;<\/p>\n<p>printf\uff08\u201c\\n\u201d\uff09;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>void Encode\uff08HuffmanCode *hc\uff0cchar *letters\uff0cchar *test\uff0cchar *code\uff09<\/p>\n<p>{<\/p>\n<p>int len=0;<\/p>\n<p>int i\uff0cj;<\/p>\n<p>for\uff08i=0;test\uff3bi\uff3d\uff01=\u2018\\0\u2019;i++\uff09<\/p>\n<p>{<\/p>\n<p>for\uff08j=0;letters\uff3bj\uff3d\uff01=test\uff3bi\uff3d;j++\uff09{}<\/p>\n<p>strcpy\uff08code+len\uff0chc\uff3bj\uff3d\uff09;<\/p>\n<p>len=len+strlen\uff08hc\uff3bj\uff3d\uff09;<\/p>\n<p>}<\/p>\n<p>printf\uff08\u201cThe Test \uff1a %s \\nEncode to be \uff1a\u201d\uff0ctest\uff09;<\/p>\n<p>printf\uff08\u201c%s\u201d\uff0ccode\uff09;<\/p>\n<p>printf\uff08\u201c\\n\u201d\uff09;<\/p>\n<p>}<\/p>\n<p>void Decode\uff08HuffmanTree *HT\uff0cint m\uff0cchar *code\uff0cchar *letters\uff09<\/p>\n<p>{<\/p>\n<p>int posi<a class=\"blue\" title=\"TI\u793e\u533a\" href=\"http:\/\/bbs.elecfans.com\/zhuti_715_1.html\" target=\"_blank\" rel=\"noopener noreferrer\">TI<\/a>on=0\uff0ci;<\/p>\n<p>printf\uff08\u201cThe Code\uff1a %s \\nDecode to be \uff1a\u201d\uff0ccode\uff09;<\/p>\n<p>while\uff08code\uff3bposi<a class=\"blue\" title=\"TI\u793e\u533a\" href=\"http:\/\/bbs.elecfans.com\/zhuti_715_1.html\" target=\"_blank\" rel=\"noopener noreferrer\">TI<\/a>on\uff3d\uff01=\u2018\\0\u2019\uff09<\/p>\n<p>{<\/p>\n<p>for\uff08i=m-1;HT\uff3bi\uff3d.Leftchild\uff01=-1&amp;&amp;HT\uff3bi\uff3d.Rightchild\uff01=-1;position++\uff09<\/p>\n<p>{<\/p>\n<p>if\uff08code\uff3bposition\uff3d==\u20180\u2019\uff09<\/p>\n<p>i=HT\uff3bi\uff3d.Leftchild;<\/p>\n<p>else<\/p>\n<p>i=HT\uff3bi\uff3d.Rightchild;<\/p>\n<p>}<\/p>\n<p>printf\uff08\u201c%c\u201d\uff0cletters\uff3bi\uff3d\uff09;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>int main\uff08\uff09<\/p>\n<p>{<\/p>\n<p>int n=27;<\/p>\n<p>int m=2*n-1;<\/p>\n<p>char letters\uff3b28\uff3d={\u2018a\u2019\uff0c\u2018b\u2019\uff0c\u2018c\u2019\uff0c\u2018d\u2019\uff0c\u2018e\u2019\uff0c\u2018f\u2019\uff0c\u2018g\u2019\uff0c\u2018h\u2019\uff0c\u2018i\u2019\uff0c\u2018j\u2019\uff0c\u2018k\u2019\uff0c\u2018l\u2019\uff0c\u2018m\u2019\uff0c<\/p>\n<p>\u2018n\u2019\uff0c\u2018o\u2019\uff0c\u2018p\u2019\uff0c\u2018q\u2019\uff0c\u2018r\u2019\uff0c\u2018s\u2019\uff0c\u2018t\u2019\uff0c\u2018u\u2019\uff0c\u2018v\u2019\uff0c\u2018w\u2019\uff0c\u2018x\u2019\uff0c\u2018y\u2019\uff0c\u2018z\u2019\uff0c\u2018 \u2019};<\/p>\n<p>int w\uff3b28\uff3d={64\uff0c13\uff0c22\uff0c32\uff0c103\uff0c21\uff0c15\uff0c47\uff0c57\uff0c1\uff0c5\uff0c32\uff0c20\uff0c<\/p>\n<p>57\uff0c63\uff0c15\uff0c1\uff0c48\uff0c51\uff0c80\uff0c23\uff0c8\uff0c18\uff0c1\uff0c16\uff0c1\uff0c168};<\/p>\n<p>char code\uff3b200\uff3d;<\/p>\n<p>char test\uff3b50\uff3d={\u201cthis is about build my life\u201d};<\/p>\n<p>HuffmanTree *HT;<\/p>\n<p>HuffmanCode *hc;<\/p>\n<p>HT=\uff08HuffmanTree *\uff09malloc\uff08m*sizeof\uff08HuffmanTree\uff09\uff09;<\/p>\n<p>hc=\uff08HuffmanCode *\uff09malloc\uff08n*sizeof\uff08char*\uff09\uff09;<\/p>\n<p>CreateTree\uff08HT\uff0cn\uff0cw\uff09;<\/p>\n<p>Print\uff08HT\uff0cm-1\uff09;<\/p>\n<p>printf\uff08\u201c\\n\u201d\uff09;<\/p>\n<p>Huffmancoding\uff08HT\uff0cn\uff0chc\uff0cletters\uff09;<\/p>\n<p>Encode\uff08hc\uff0cletters\uff0ctest\uff0ccode\uff09;<\/p>\n<p>Decode\uff08HT\uff0cm\uff0ccode\uff0cletters\uff09;<\/p>\n<p>printf\uff08\u201c\\n\u201d\uff09;<\/p>\n<p>return 0;<\/p>\n<p>}<\/p>\n<p><em><strong>\u3000\u3000\u63a8\u8350\u9605\u8bfb\uff1a<\/strong><\/em><\/p>\n<p><a href=\"http:\/\/www.elecfans.com\/emb\/600183.html\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>\u3000\u3000c\u8bed\u8a00\u5982\u4f55\u5b9e\u73b0\u54c8\u592b\u66fc\u7f16\u7801\u4e0e\u8bd1\u7801<\/strong><\/em><\/a><\/p>\n<p><a href=\"http:\/\/www.elecfans.com\/emb\/600103.html\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>\u3000\u3000java\u5b9e\u73b0\u7684\u54c8\u592b\u66fc\u7f16\u7801\u4e0e\u89e3\u7801<\/strong><\/em><\/a><\/p>\n<p><a href=\"http:\/\/www.elecfans.com\/rengongzhineng\/600143.html\" target=\"_blank\" rel=\"noopener noreferrer\"><em><strong>\u3000\u3000\u54c8\u592b\u66fc\u7b97\u6cd5\u7684\u7406\u89e3\u53ca\u539f\u7406\u5206\u6790\uff0c\u7b97\u6cd5\u5b9e\u73b0\uff0c\u6784\u9020\u54c8\u592b\u66fc\u6811\u7684\u7b97\u6cd5<\/strong><\/em><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u5730\u5740 &nbsp; \u3000\u3000\u6458\u8981\uff1a\u4f5c\u4e3a\u4e00<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[119],"class_list":["post-4015","post","type-post","status-publish","format-standard","hentry","tag-03-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/4015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=4015"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/4015\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=4015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=4015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=4015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}