题解 | #字符统计#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String s = sc.nextLine();
char[] carr = s.toCharArray();
int [] arr = new int[129];
StringBuilder sb = new StringBuilder();
for(char c : carr){
arr[(int)c]++;
}
int max =0;
for(int i =0;i<arr.length;i++){
if(max < arr[i]){
max = arr[i];
}
}
while(max !=0){
for(int i = 0; i< arr.length;i++){
if(arr[i] == max){
sb.append((char)i);;
}
}
max--;
}
System.out.println(sb.toString());
}
}
}
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String s = sc.nextLine();
char[] carr = s.toCharArray();
int [] arr = new int[129];
StringBuilder sb = new StringBuilder();
for(char c : carr){
arr[(int)c]++;
}
int max =0;
for(int i =0;i<arr.length;i++){
if(max < arr[i]){
max = arr[i];
}
}
while(max !=0){
for(int i = 0; i< arr.length;i++){
if(arr[i] == max){
sb.append((char)i);;
}
}
max--;
}
System.out.println(sb.toString());
}
}
}