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

2018-09-19  本文已影响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);
             }

}
上一篇 下一篇

猜你喜欢

热点阅读