add Compression ratio
This commit is contained in:
9
main.cpp
9
main.cpp
@@ -170,8 +170,11 @@ int main(){
|
|||||||
Huffman Huffman1(a);
|
Huffman Huffman1(a);
|
||||||
char b[800]={'\0'};
|
char b[800]={'\0'};
|
||||||
char c[100]={'\0'};
|
char c[100]={'\0'};
|
||||||
|
int nb = -1,nc = -1;
|
||||||
Huffman1.Encode(a,b);
|
Huffman1.Encode(a,b);
|
||||||
Huffman1.Decode(b,c);
|
Huffman1.Decode(b,c);
|
||||||
|
while(b[++nb] != '\0');
|
||||||
|
while(c[++nc] != '\0');
|
||||||
system(CLEAR);
|
system(CLEAR);
|
||||||
cout <<"+----------------------------+"<<endl;
|
cout <<"+----------------------------+"<<endl;
|
||||||
cout <<"| 哈弗曼树实现 |"<<endl;
|
cout <<"| 哈弗曼树实现 |"<<endl;
|
||||||
@@ -185,6 +188,12 @@ int main(){
|
|||||||
cout <<"|"<<setw(28)<<setiosflags(ios::left)<<c<<"|"<<endl;
|
cout <<"|"<<setw(28)<<setiosflags(ios::left)<<c<<"|"<<endl;
|
||||||
cout <<"| 按Enter进入菜单 |"<<endl;
|
cout <<"| 按Enter进入菜单 |"<<endl;
|
||||||
cout <<"+----------------------------+"<<endl;
|
cout <<"+----------------------------+"<<endl;
|
||||||
|
cout <<"编码前长度"<<endl;
|
||||||
|
cout << nc*8 << endl;
|
||||||
|
cout << "编码后长度" <<endl;
|
||||||
|
cout << nb << endl;
|
||||||
|
cout << "压缩率" << endl;
|
||||||
|
cout << (double)nb/(nc*8) << endl;
|
||||||
cin.get();cin.get();
|
cin.get();cin.get();
|
||||||
int chouse;
|
int chouse;
|
||||||
goback:;
|
goback:;
|
||||||
|
|||||||
Reference in New Issue
Block a user