• 大小: 4.91MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-20
  • 语言: C/C++
  • 标签: c++  数据结构  

资源简介

题目:利用哈夫曼编码进行对已有文件进行重新编码可以大大提高减小文件大小,减少存储空间。但是,这要求在首先对一个现有文件进行编码行成新的文件,也就是压缩。在文件使用时,再对压缩文件进行解压缩,也就是译码,复原原有文件。试为完成此功能,写一个压缩/解压缩软件(控制台程序,不要求界面)。 详细讲解请参考文章:https://blog.csdn.net/weixin_44387644/article/details/105906221

资源截图

代码片段和文件信息

// Compress(Decompress) Software.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“
#include 
#include “HuffmanTree.h“
using namespace std;

void main()
{
int nChoice = 1;
char pcInput[255] pcOutput[255];
HuffmanTree h;
while (nChoice)
{
cout << “【Compression and Decompression of Files——Szip】“ << endl;
cout << “Please enter characters to select functions:“ << endl;
cout << “* 1:Compression“ << endl;
cout << “* 2:Decompression“ << endl;
cout << “* 3:Comparing the original file with the decompressed file“ << endl;
cout << “——————————————————————————“< cin >> nChoice;
switch (nChoice)
{
case 1:
{
  cout << “Please enter the absolute path of the file to be compressed:“;
  cin >> pcInput;
  cout << “Please enter the compressed file absolute path: “;
  cin >> pcOutput;
 
  if (h.doCompress(pcInput pcOutput))
  {
  h.compareCompressFile(pcInput pcOutput);
  cout << endl << “Successful file compression!“ << endl;
  }
  else
  {
  cout << endl << “File compression failed! “ << endl;
  }
}
break;
case 2:
{
  cout << “Please enter the unzipped file name: “;
  cin >> pcInput;
  cout << “Please enter the unzipped file name: “;
  cin >> pcOutput;
  if (h.doDecompress(pcInput pcOutput))
  {
  cout << endl << “The file was decompressed successfully! “ << endl;
  //h.compareDecompressFile(input output);
  }
  else
  cout << endl << “File decompression failed! “ << endl;
}
break;
case 3:
{
  cout << “Please enter the file name of the original file:“;
  cin >> pcInput;
  cout << “Please enter the unzipped file name:“;
  cin >> pcOutput;
  h.compareDecompressFile(pcInput pcOutput);
}
break;
default:
cout << “Please input the instructions correctly!“ << endl;
break;
}
cout << endl;
}
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-12-19 21:01  Compress(Decompress) Software\
     文件       11219  2019-01-11 09:02  Compress(Decompress) Software\1.txt
     文件           0  2019-12-19 21:01  Compress(Decompress) Software\2.txt
     文件           3  2019-12-19 21:01  Compress(Decompress) Software\3.txt
     文件          42  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software.opensdf
     文件     8650752  2019-12-19 21:02  Compress(Decompress) Software\Compress(Decompress) Software.sdf
     文件        1033  2019-01-10 09:43  Compress(Decompress) Software\Compress(Decompress) Software.sln
     文件       26112  2019-01-16 22:35  Compress(Decompress) Software\Compress(Decompress) Software.v12.suo
     目录           0  2019-01-16 22:35  Compress(Decompress) Software\Compress(Decompress) Software\
     文件         654  2019-01-16 21:22  Compress(Decompress) Software\Compress(Decompress) Software\ClassDiagram.cd
     文件        2018  2019-01-16 21:46  Compress(Decompress) Software\Compress(Decompress) Software\Compress(Decompress) Software.cpp
     文件        4733  2019-01-16 21:22  Compress(Decompress) Software\Compress(Decompress) Software\Compress(Decompress) Software.vcxproj
     文件        1595  2019-01-16 21:22  Compress(Decompress) Software\Compress(Decompress) Software\Compress(Decompress) Software.vcxproj.filters
     目录           0  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\
     文件        1569  2019-01-10 17:05  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress(Decompress) Software.Build.CppClean.log
     文件        2474  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress(Decompress) Software.log
     文件      179482  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress(Decompress) Software.obj
     文件     2162688  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress(Decompress) Software.pch
     目录           0  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\
     文件        5686  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\cl.command.1.tlog
     文件       23724  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\CL.read.1.tlog
     文件        6444  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\CL.write.1.tlog
     文件         225  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\Compress(Decompress) Software.lastbuildstate
     文件        3982  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\link.command.1.tlog
     文件        6830  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\link.read.1.tlog
     文件        2342  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\Compress.2C8B577F.tlog\link.write.1.tlog
     文件      366600  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\HuffmanTree.obj
     文件       12272  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\stdafx.obj
     文件      502784  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\vc120.idb
     文件      462848  2019-12-19 21:01  Compress(Decompress) Software\Compress(Decompress) Software\Debug\vc120.pdb
     文件       12096  2019-01-16 22:35  Compress(Decompress) Software\Compress(Decompress) Software\HuffmanTree.cpp
............此处省略15个文件信息

评论

共有 条评论