www.pudn.com > haffman.zip > HUFF_MAN.cpp, change:2009-11-14,size:494b


#include"HUFF_MAN.h" 
 
void main() 
{ 
	HuffmanTree HT; 
	HuffmanCode HC; 
	int *w,n; 
	int i; 
	cout<<"请输入要输入的字符个数:"; 
	cin>>n; 
	if(n<=1) 
	{ 
		cout<<"程序不符合最小要求..."<<endl; 
		system("pause"); 
		exit(0); 
	} 
	w=new int [n+1]; 
	for(i=1;i<=n;i++) 
	{ 
		cout<<"请输入第"<<i<<"个字符的权值:"; 
		cin>>*(w+i); 
	} 
    HuffmanCoding(HT,HC,w,n); 
	for(i=1;i<=n;i++) 
	{ 
		cout<<"赫夫曼编码为..."<<endl; 
		cout<<"第"<<i<<"个字符:"<<*(HC+i)<<endl; 
	} 
	system("pause"); 
}