输入描述:
输入第一行为一个正整数n(1≤n≤1000),下面n行为n个字符串(字符串长度≤100),字符串中只含有大小写字母。
输出描述:
数据输出n行,输出结果为按照字典序排列的字符串。
即为将字符串每个字符转成ASCII,比较ASCII值的大小。
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()){
String num = scanner.nextLine();
int n = Integer.parseInt(num);
String str[] = new String[n];
for(int i =0;i<n;i++){
str[i] = scanner.nextLine();
}
Method.dicSort(str);
}
}
}
class Method{
//字典排序
public static void dicSort(String[] str){
int len = str.length;
//冒泡排序
for(int i = 0;i < len;i++){
for(int j = i;j<len;j++){
if(aBigThanb(str[i],str[j])){
String temp = str[i];
str[i] = str[j];
str[j] = temp;
}
}
}
for(int i =0;i<len;i++){