Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public char analyse(String geheimtext){
  2. int[]zähler = new int[26];
  3. int pos= 0;
  4. char key;
  5. for(int i=0;i<geheimtext.length(); i++){
  6. zähler[(int)geheimtext.charAt(i)-65] = zähler[(int)geheimtext.charAt(i)-65] + 1;}
  7.  
  8.  
  9. for(int i=0; i< zähler.length;i++){
  10. if( zähler[i]>zähler[pos]){
  11. pos=i;
  12. }
  13. }
  14. key = (char) (65+ pos-4);
  15. System.out.println("H " + (int) key);
  16.  
  17. if((int)key<65){
  18. key += 26;
  19. }
  20. return key;
  21.  
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement