Huffman编码完整源代码(VS2010调试通过): ****************************main.CPP***************************** #include"huffman.cpp" int main() { cout << "******************欢迎使用哈夫曼压缩软件****************\n"; cout << "┏━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n"; cout << "┃ ┃ ┃\n"; cout << "┃ ┃ ┃\n"; cout << "┃ 1:哈夫曼压缩 ┃ 2:哈夫曼解压 ┃\n"; cout << "┃ ┃ ┃\n"; cout << "┃ ┃ ┃\n"; cout << "┣━━━━━━━━━━━━╋━━━━━━━━━━━━━┫\n"; cout << "┃ ┃ ┃\n"; cout << "┃ ┃ ┃\n"; cout << "┃ 3:使用说明 ┃ 4:退出程序 ┃\n"; cout << "┃ ┃ ┃\n"; cout << "┃ ┃ ┃\n"; cout << "┗━━━━━━━━━━━━┻━━━━━━━━━━━━━┛\n"; cout << "**********************sgyy 2011*************************\n"; cout< #include #include #include #include #include #include using namespace std; void input();//功能选择 void compress();//压缩 void uncompress();//解压 void help();//帮助 clock_t start,finish;//记录压缩/解压时间 double time1;//存放压缩和解压时间; struct head { unsigned char b; long count; long parent,lch,rch; char bits[256]; } header[512],tmp; fpos_t filelen( ifstream& file ) { fstream::pos_type cur_pos = file.tellg(); file.seekg( 0L, ios::end ); fstream::pos_type end_pos = file.tellg(); file.seekg( cur_pos, ios::beg ); return end_pos.seekpos(); } int getsize(char file[]) //获取文件大小 { ifstream infile(file); fpos_t len = filelen( infile ); return len/1024; } void input() { int a; cout<<"请选择功能(输入1、2、3或 4)......"; cin>>a; cout<