package hello;
public class SortLetter {
public static void main(String[] args) {
String s = "ueurybbc";
String ns = Sort01(s);
System.out.println(ns);
}
public static String Sort01(String s){
char[] ch = s.toCharArray();
char cur;
StringBuffer sb = new StringBuffer();
for(int j = 0; j<ch.length-1;j++){
for(int i = 0;i<ch.length-1-j;i++){
if(ch[i+1] < ch[i]){
cur = ch[i];
ch[i] = ch[i+1];
ch[i+1] = cur;
}
}
}
return new String(ch);
}
}
JAVA字符排序--冒泡排序法
最新推荐文章于 2024-01-24 11:57:08 发布