import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
char[] c=new char[str.length()];
for (int i=0;i<c.length;i++){
c[i]=str.charAt(i);
}
//获取字符串中出现次数最多的字母,不分大小写
char[] word={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int[] count={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
for (int i=0;i<word.length;i++){
for (int j=0;j<c.length;j++){
if (word[i]==c[j]||word[i]==c[j]+32){
count[i]++;
}
}
}
//以上为获取的字母重复次数,现在比较大小
bgm:for (int i=0;i<count.length;i++){
for (int j=0;j<count.length;j++){
if(count[i]>=count[j]){
if (j==count.length-1){
System.out.println(word[i]+" "+count[i]);
break bgm;
}
}else{
break;
}
}
}
}
}
1042(20)
最新推荐文章于 2022-03-01 17:11:03 发布