标签:style blog color java for ar div amp
AC CODE:
import java.util.Scanner; public class Main { private static char[] ASCII = { ‘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‘ }; private static String getString() { Scanner input = new Scanner(System.in); return input.nextLine(); } private static boolean isLetter(char c) { if ((‘a‘ <= c) && (c <= ‘z‘)) { return true; } return false; } private static int[] getSortArray(String str, int[] letters) { for (int i = 0; i < str.length(); i++) { if (isLetter(str.charAt(i))) { letters[str.charAt(i) - ‘a‘]++; } } return letters; } public static void main(String[] args) { String str = getString(); int[] letters = new int[26]; letters = getSortArray(str, letters); for (int i = 0; i < letters.length; i++) { for (int j = 0; j < letters[i]; j++) { System.out.print(ASCII[i] + ""); } } System.out.print("\n"); } }
标签:style blog color java for ar div amp
原文地址:http://www.cnblogs.com/Stone-sqrt3/p/3915556.html