importjava.util.*;publicclass 垂直柱状图 {publicstaticvoidmain(String[] args){Scanner sc =newScanner(System.in);int[] char_counter =newint[26];//26个字母for(int i =0; i <4; i++){String str = sc.nextLine();for(int j =0; j < str.length(); j ++){if(str.charAt(j)>='A'&& str.charAt(j)<='Z'){
char_counter[str.charAt(j)-'A']++;//确定每个字母出现的次数}}}int max=0;for(int i =0; i <=25; i++){//找出字母次数出现的最大次数
max =Math.max(char_counter[i], max);}for(int i =max ; i >=1; i--){//从最大的次数从上往下遍历for(int j =0; j <=25; j++){//26个字母从左往右遍历if(char_counter[j]>= i){System.out.print("* ");}else{System.out.print(" ");}}System.out.println();}System.out.println("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");}}