来的赫夫曼树是:");Р for(k = 1; k <= 2*i -1; ++k)Р {Р printf("\n%3d---weight:%3d,parent:%3d,lchild:%3d,rchild:%3d",Р k,HT[k].weight,HT[k].rchild,HT[k].rchild,HT[k].lchild);Р }Р}Рvoid printcode(HuffmanTree HT,HuffmanCode HC,int n)Р//输出得到的各权Huffman编码Р{Р int j;Р printf("得到的各权Huffman编码是:\n");Р for(j=1; j <= n; j++)Р {Р printf("\nwieght:%3d Code:%s\n",HT[j].weight,HC[j]);Р }Р}Рvoid main()Р{Р int i = 0, *w;Р HuffmanTree HT;Р HuffmanCode HC;Р w = (int *)malloc(MAXSIZE * sizeof(int));Р printf("请输入每个叶子权值(输入0结束:)\n");Р scanf("%d",&w[i]);Р getchar();Р for(i = 1; w[i-1]; i++)Р {Р scanf("%d", &w[i]);Р getchar();Р }Р w[i-1] = '\0';Р CreateHuffmanTree(HT, w, i-1); Р printf("\n从叶子到根逆向求每个字符的赫夫曼编码");Р print(HT,i-1);Р printf("\n");Р HuffmanCoding(HT, HC, i-1);Р printcode(HT,HC,i-1);Р free(HT);Р free(HC);Р}Р运行与测试及结果: