【程序40】
题目:字符串排序。(字典顺序)
package com.gyy.exercise;
import java.util.Arrays;
import java.util.Scanner;
public class Exercise40 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
String str = console.next();
char[] c = str.toCharArray();
for(int i = 0; i < str.length() - 1; i++){
for(int j = 0; j < str.length() - i - 1; j++)
{
char temp;
if(c[j] > c[j+1])
{
temp = c[j];
c[j] = c[j+1];
c[j+1] = temp;
}
}
}
System.out.println(Arrays.toString(c));
}
}