#include<iostream>
#include<stdio.h>
#include"huffman.h"
#include"input.h"
using namespace std;
void main()
{
int i=0,j=0,t=0,p=1;
char c,str[Max],de[Max];
ABC abc[M],a[M];
cout<<"输入待编码的字符串:";
In(str,i,t,abc);
for(int q=0;q<M;q++)
{
if(abc[q].weight!=0)
{
cout<<abc[q].data<<" "<<abc[q].weight<<endl;
a[p++]=abc[q];
}
}
HuffMan H(t,a);
H.makeTree();
H.huffmanCode();
H.outputcode();
cout<<"字符串编码后的结果是:";
H.strcode(str,i);
cout<<"输入编码,我给你译码(等于号结束):"<<endl;
while (i<Max-1 && (c=getchar())!=EOF && c!='\n')
de[j++]=c;
de[j]='\0';
H.decode(de);
}