All pastes #987700 Raw Edit

Jemand

public text v1 · immutable
#987700 ·published 2008-04-16 19:42 UTC
rendered paste body
    public static void attackVer(String str)
    {
        String alphabet = new String("abcdefghijklmnopqrstuvwxyz");
        char[]alpha = alphabet.toCharArray();
        char[]eingabe = str.toCharArray();
            for (int j=0; j <26; j++){
                int anzahl=0;
                for (int i= 0; i < str.length(); i++)
                {
                    if (alpha[j] == str.charAt(i)){
                        anzahl = anzahl +1;
                      
                    }    
                }
                anzahlDerBuchstaben[j] = anzahl;
               
            }
         double[] haeufigkeit =new double[26];
         for(int k =0; k < 26; k++){
            haeufigkeit[k]= ((double)anzahlDerBuchstaben[k] / str.length()) *100;
            }
         double[] geordneteHaeufigkeiten = Arrays.copyOf(haeufigkeit, haeufigkeit.length);
         Arrays.sort(geordneteHaeufigkeiten);

         System.out.println(haeufigkeit[4]);
     }
     static int[] anzahlDerBuchstaben = new int[26];             

}