1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import java.util.Scanner; /** * UVA10008 */ public class UVA10008 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String temp = sc.nextLine(); temp = temp.replace(" ", ""); int num = Integer.parseInt(temp); int[] count = new int[26]; int max = 0; for (int i = 0; i < num; i++) { temp = sc.nextLine().toLowerCase(); for (int j = 0; j < temp.length(); j++) { if (temp.charAt(j) <= 122 && temp.charAt(j) >= 97) { count[temp.charAt(j) - 97]++; if (count[temp.charAt(j) - 97] > max) max = count[temp.charAt(j) - 97]; } } } for (int i = max; i > 0; i--) for (int j = 0; j < count.length; j++) { if (i == count[j]) System.out.println((char) (j + 65) + " " + count[j]); } sc.close(); } } |