Original question address
Description
After three characters are entered (repeated), the three characters are output in ascending order of the ASCII code of each character.
Input
Enter N in the first line, indicating that there are N groups of test data. The next n rows Input Multiple groups of data. Each group of input data occupies one row and consists of three characters without spaces.
Output
For each group of input data, one line is output, separated by a space.
Sample Input
3
Qwe
ASD
Zxc
Sample output
§ E Q W
A D S
C x Z
The Code is as follows:
public static void main(String[] args){Scanner sc = new Scanner(System.in);int count = sc.nextInt();while(count > 0){String str = sc.next();char[] chr = str.toCharArray();java.util.Arrays.sort(chr);for(int j = 0; j < chr.length; j++){System.out.print(chr[j]+" ");}count --;}}
Please do not give me any advice on what is better about all roads.
This article from "One step at a footprint" blog, please be sure to keep this source http://wangrz421.blog.51cto.com/6243726/1549004
Sort ACM--ASCII Codes