class node{           //定义一个节点的类
char character;//字符码
int weight;//权值
Boolean leaf = false;//是否是叶子节点

public node(char c,int w){
character = c;
weight = w;
}
public node(char c,int w,Boolean l){
character = c;
weight = w;
leaf = l;
}
}      
   public class HaffmanCode1{

     /*初始化段落
          */
public static void main(String args[]) throws IOException{}
    }
         这是一个关于哈夫曼编码的问题,本人初学Java,现在需要初始化如图的一组字符和权值:
          
        自己写老标识出错,请求高人指点,帮忙写下!!

解决方案 »

  1.   


    -- A B C D E F G H I J
    186 64 13 22 32 103 21 15 47 57K       L       M
    5 32 20N O P Q R S T U V W X
    57 63 15 1 48 51 80 23 8 18 1    
    Y       Z
    16 1
    图片显示不出来,是这样一组字符和权值;
      

  2.   


    node[] n = new node[26];for(int i=0;i<26;i++) {
      node[i].character = (char)(65+i);
    }
    至于权值的赋值,找不到规律,就一个个来吧
      

  3.   

    public static int arrayInt[] ={186,64,13,22,32,103,21,15,47,57,1,5,32,20,57,63,15,1,48,51,80,23,8,
                      18,1,16,1};
      public static char arrayChar[] ={'-','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
                     'P','Q','R','S','T','U','V','W','X','Y','Z'};

    public static void main(String args[]) throws IOException{

    Node arrayNode[] = new Node[SIZE]; 

    for(int i=0; i<SIZE ;i++){
       arrayNode[i] =new Node(arrayChar[i],arrayInt[i],true); 
    }这个方法后来想出来的
      

  4.   

    初学java都研究这问题了?我学了1年了,说实话,还闹不明白你这甚意思?