main.cpp

来自「huffman coding ke yi ce shi jian , you l」· C++ 代码 · 共 48 行

CPP
48
字号


#include "defines.h"




void main()
{
	vector<string> codeResult;
	vector<hNode> huffmanTree;
	string iFileName("input.txt");

	cout << "please input your file: " << endl;
//	cin >> iFileName;
/*	string oFileName("input.txt");
	ofstream outFile(oFileName.c_str());
	for(int ix = 0; ix < 26; ix++)
	{
		for(int iy = 0; iy <= ix; iy++)
		{
			outFile.put( 'a' + ix);
		}
	}
	outFile.close();*/


	ifstream inFile(iFileName.c_str());

	if(!inFile)
	{
		cout << "unable open " << iFileName << endl;
		cout << "please check the file name!" << endl;
	}

	GatherData(inFile, huffmanTree);
	CheckData(huffmanTree,"src.txt");

	CreatHuffmanTree(huffmanTree);
	CheckData(huffmanTree,"rate.txt");

	HuffmanCoding(huffmanTree, codeResult);
//	CheckData(codeResult,"code.txt");

}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?