解题思路:
import java.util.Scanner; public class C1251 { public static void main(String[] args) { int[] a = new int[26]; Scanner sc = new Scanner(System.in); while (sc.hasNext()) { boolean isEnd = false; char[] chs = sc.nextLine().toCharArray(); for(char ch : chs){ if(ch == '#'){ isEnd = true; break; }else if(ch >= 'a' && ch <= 'z'){ a[ch-'a']++; } } if(isEnd) break; } for(int i = 0; i < 26; i++){ System.out.println((char)('a'+i) + " " + a[i]); } sc.close(); } }
注意事项:
参考代码:
0.0分
0 人评分