Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class October_6th_2 { //не забудьте переименовать класс =)
- static public void main(String[] args){
- String string = new Scanner(System.in).nextLine();
- char[] charArray = new char[string.length()];
- for(int i = 0; i < charArray.length; i ++){
- charArray[i] = string.charAt(i);
- }
- System.out.println("Symbol is: " + findTheMostSymbol(charArray));
- }
- static public char findTheMostSymbol(char[] charArray){
- char symbol = '0';
- int count = -1;
- for(char c: charArray){
- int local_count = 0;
- for(int i = 0; i < charArray.length; i++){
- if(charArray[i] == c){
- local_count ++;
- }
- }
- if(local_count > count){
- count = local_count;
- symbol = c;
- }
- }
- return symbol;
- }
- }
Add Comment
Please, Sign In to add comment