美文网首页
计算一个英文文章26个英文字母产生的频率

计算一个英文文章26个英文字母产生的频率

作者: 南娇 | 来源:发表于2018-09-19 17:14 被阅读57次

    优于别人并不高贵,真正的高贵是优于过去的自己

      private String str="On Friendship\n" +
            "\n" +
            "And a youth said, \"Speak to us of Friendship.\"\n" +
            "\n" +
            "Your friend is your needs answered.\n" +
            "\n" +
            "He is your field which you sow with love and reap with thanksgiving.\n" +
            "\n" +
            "And he is your board and your fireside.\n" +
            "\n" +
            "For you come to him with your hunger, and you seek him for peace.\n" +
            "\n" +
            "When your friend speaks his mind you fear not the \"nay\" in your own mind, nor do you withhold the \"ay.\"\n" +
            "\n" +
            "And when he is silent your heart ceases not to listen to his heart;\n" +
            "\n" +
            "For without words, in friendship, all thoughts, all desires, all expectations are born and shared, with joy that is unacclaimed.\n" +
            "\n" +
            "When you part from your friend, you grieve not;\n" +
            "\n" +
            "For that which you love most in him may be clearer in his absence, as the mountain to the climber is clearer from the plain. ";
    
      public void get(){
    
            char [] strs=str.toCharArray();
    
              int [] a=new int[123];
    
                 for(int i=0;i<strs.length;i++){
                     int x=strs[i];
                   a[x]++;
               }
    
              for(int j=0;j<a.length;j++){
                    Log.e("TAG",a[j]+"---->"+(char)j);
                 }
    
    }

    相关文章

      网友评论

          本文标题:计算一个英文文章26个英文字母产生的频率

          本文链接:https://www.haomeiwen.com/subject/jtninftx.html