排序问题
程序员文章站
2024-01-15 18:56:34
...
package corejava;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
* (机能概要描述)
*
* <pre>
* [变更履历]
* 09.07.20.NICKLE NET 初版
* </pre>
*
* @author NICKLE)王
*/
public class TempTest {
public String inputInteger() throws Exception{
System.out.println("please input integer");
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String temp = bf.readLine();
return temp;
}
public void orderTest(String str){
final int count = str.length();
String[] str1 = new String[count];
String temp = null;
for(int i = 0 ; i< count ; i++){
str1[i] = str.substring(i,i+1);
}
for(int i = 0 ; i < count ; i++){
for(int j = i ; j< count ;j++){
if(str1[i].compareTo(str1[j]) > 0 ){
temp = str1[j];
str1[j] = str1[i];
str1[i]= temp;
}
}
}
for(String str2:str1){
System.out.print(str2 + " ");
}
}
public static void main(String[] args) throws Exception{
TempTest t = new TempTest();
String str = t.inputInteger();
t.orderTest(str);
}
}
上一篇: html图片等比缩放
下一篇: Glide 图片等比缩放