- 0
- 0
- 约 16页
- 2017-08-31 发布于河南
- 举报
huffman树压缩文件程序(Huffman tree compressed file program)
huffman树压缩文件程序(Huffman tree compressed file program)
Huffman tree compression file program (share with you ah)
2008-06-28 21:41 (| classification: default classification)
Six, detailed design: (ha ha,, after you see, dont forget to leave footprints!)
#include stdafx.h
#include stdio.h
#include string.h
#include stdlib.h
#include conio.h
Struct head
{
Unsigned char b;
Long count;
Long, parent, LCH, rch;
Char bits[256];
}
Header[512], tmp;
Void, compress ()
{
Char, filename[255], outputfile[255], buf[512];
Unsigned char c;
Long, I, J, m, N, f;
Long, Min1, pT1, flength, length1, length2;
Double div;
FILE, *ifp, *ofp;
Printf (please, enter, your, file, name (for, example:luyifa.txt):\n);
Gets (filename);
Ifp=fopen (filename, Rb);
If (ifp==NULL)
{
Printf (\n, opening, file, is, fail, \n\n);
Return;
}
Printf (please, enter, compressed, file, name (for, example:618.txt):\n);
Gets (outputFile);
Ofp=fopen (strcat (outputFile, .Txt), WB);
If (ofp==NULL)
{
Printf (\n, Compressing, file, is, fail, \n\n);
Return;
}
Flength=0;
While (... Feof (IFP))
{
FREAD (c, 1,1, IFP);
Header[c].count++;
Flength++;
}
Flength--;
Length1=flength;
Header[c].count--;
For (i=0; i512; i++)
{
If (header[i].count, =0) header[i].b= (unsigned, char) i;
Else header[i].b=0;
Header[i].parent=-1; header[i].lch=header[i].rch=-1;
}
For (i=0; i256; i++)
{
For (j=i+1; j256; j++)
{
If (header[i].countheader[j].count)
{
Tmp=header[i];
Header[i]=header[j];
Header[j]=tmp;
}
}
}
For (i=0; i256; i++)
If (header[i].count==0)
Break;
N=i;
M=2*n-1;
For (i=n; im; i++)
{
Min1=999999999;
For (j=0; ji; j++)
{
If (header[j].parent, =-1) continue;
If (min1header[j].count)
{
Pt1=j;
Min1=header[j].count;
Continue;
}
}
Header[i].count=header[pt1].count;
Header[pt1].parent=i;
Header[i].lch=pt1;
Min1=999999999;
For (j=0; ji; j++)
{
If (header[j].parent, =-1) continue;
If (min1header[j].count)
{
Pt1=j;
Min1=header[j].count;
Continue;
}
}
Header[i].count+=header[pt1].count;
Header[i].rch=pt1;
Header[pt1].parent=i;
}
For (i=0; in; i++
您可能关注的文档
- 2014年健康漆十大品牌(2014 health paint ten brands).doc
- 2014年全国法律硕士(法学)联考真题专业基础课(The master of law (Law) 2014 entrance exam Zhenti professional basic courses).doc
- 2014年度中小学教师中高级职称网络考试(2014, primary and secondary school teachers, senior title examination).doc
- 2014年度职业卫生复习题(Review of occupational health in 2014).doc
- 2014年中级统计师考试真题答案(2014 intermediate statistician exam answer).doc
- 2014年度职业生涯规划(2014 career planning).doc
- 2014年最新亚马逊卖家运营测试-试题及答案-开店考试-满分(2014's latest Amazon seller operational test - questions and answers - open shop exams - full marks).doc
- 2014年生态板十大品牌_板材质量区别(In 2014 ten major brands _ ecological quality difference).doc
- 2014年电大程序设计基础记分作业1答案(2014 TV program design basic scoring homework 1 answer).doc
- 2014年电大程序设计基础记分作业2答案(2014 TV program design basic scoring homework 2 answer).doc
- 小区绿化施工协议书.docx
- 墙面施工协议书.docx
- 1 古诗二首(课件)--2025-2026学年统编版语文二年级下册.pptx
- (2026春新版)部编版八年级道德与法治下册《3.1《公民基本权利》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《4.3《依法履行义务》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.2《按劳分配为主体、多种分配方式并存》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.1《公有制为主体、多种所有制经济共同发展》PPT课件.pptx
- 初三教学管理交流发言稿.docx
- 小学生课外阅读总结.docx
- 餐饮门店夜经济运营的社会责任报告(夜间贡献)撰写流程试题库及答案.doc
最近下载
- Q_LNKJ06-2020中负荷车辆齿轮油GL-4.pdf
- SJ∕T 10460-2016 太阳光伏能源系统图用图形符号.pdf
- 新求精德语强化教程(第4版)初级1课后练习答案(改进版) .pdf VIP
- 北师大版三年级下册数学全册教学设计(配2026年春改版教材).docx
- (2026年)跌倒坠床护理综合指南PPT课件.pptx VIP
- 工程设计应急响应方案(3篇).docx VIP
- 征信简版电子版PDF个人信用报告最新版2024年可编辑带水印模板.pdf VIP
- ntvf调试资料解读.doc VIP
- 电影《色.戒》的叙事伦理.doc VIP
- 上海大学2023-2024学年第1学期《高等数学(上)》期末考试试卷(A卷)附参考答案.pdf
原创力文档

文档评论(0)