solution.java 647 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int max = 0;
        int index = 0;
        String a = "abcdefghijklmnopqrstuvwxyz";
        int b[] = new int[26];
        for (int i = 0; i < s.length(); i++) {
            b[a.indexOf(s.charAt(i))]++;
        }
        for (int j = 0; j < b.length; j++) {
            if (b[j] > max) {
                max = b[j];
                index = j;
            }
        }
        System.out.println(a.substring(index, index + 1));
        System.out.println(max);
    }
}