Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * повертаємо максимальне число
- *
- * @param text -стрічка
- * @return -максимальна кількість зпівставлень
- */
- private int count(String text){
- int Max=0;
- for(int i=0,count=0;i<text.length();i++,count=0){
- for(int k=i;k<text.length();k++){
- if(text.charAt(i)==text.charAt(k))count++;
- }
- if(count>Max){
- Max=count;
- }
- }return Max;
- }
- /**
- * виводимо знайдені символи
- * @param text-стрічка
- */
- private void printChar(String text){
- int Max=count(text);
- for(int count=0, i=0;i<text.length();i++, count=0){
- for(int k=i;k<text.length();k++){
- if(text.charAt(i)==text.charAt(k))count++;}
- if(count==Max){
- println("символ який зустрічається "+Max+" разів - '"+text.charAt(i)+"'");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement