Advertisement
Guest User

Untitled

a guest
Dec 7th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /**
  2. * повертаємо максимальне число
  3. *
  4. * @param text -стрічка
  5. * @return -максимальна кількість зпівставлень
  6. */
  7. private int count(String text){
  8. int Max=0;
  9. for(int i=0,count=0;i<text.length();i++,count=0){
  10. for(int k=i;k<text.length();k++){
  11. if(text.charAt(i)==text.charAt(k))count++;
  12. }
  13. if(count>Max){
  14. Max=count;
  15. }
  16. }return Max;
  17. }
  18.  
  19. /**
  20. * виводимо знайдені символи
  21. * @param text-стрічка
  22. */
  23. private void printChar(String text){
  24.  
  25. int Max=count(text);
  26. for(int count=0, i=0;i<text.length();i++, count=0){
  27. for(int k=i;k<text.length();k++){
  28. if(text.charAt(i)==text.charAt(k))count++;}
  29. if(count==Max){
  30. println("символ який зустрічається "+Max+" разів - '"+text.charAt(i)+"'");
  31. }
  32.  
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement