/*程序中通过修改宏定义#define max_PN 6,是消息符号的个数具有可变性,在一定意义上说有灵活性*/
/*在写完程序之后,我才发现直接使用数组也可以实现,而且省去对消息符号概率的排序,因为时间有限,我再没有编写*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define max_CL 10 /*maxsize of length of code*/
#define max_PN 6 /*输入序列的个数*/
typedef float datatype;
typedef struct SHNODE {
datatype pb; /*第i个消息符号出现的概率*/
datatype p_sum; /*第i个消息符号累加概率*/
int kl; /*第i个消息符号对应的码长*/
int code[max_CL]; /*第i个消息符号的码字*/
struct SHNODE *next;
}shnolist;
datatype sym_arry[max_PN]; /*序列的概率*/
void pb_scan(); /*得到序列概率*/
void pb_sort(); /*序列概率排序*/
void valuelist(shnolist *L); /*计算累加概率,码长,码字*/
void codedisp(shnolist *L);
void pb_scan()
{
int i;
datatype sum=0;
printf("input %d possible!/n