字符串排序冒泡法
public static void main(String
[] args
) {
String str
= "a1b2c3d4c5";
char[] chars
= str
.toCharArray();
for (int i
= 0; i
< chars
.length
; i
++) {
for (int j
= i
+ 1; j
< chars
.length
; j
++) {
if (chars
[i
] > chars
[j
]) {
char temp
= chars
[i
];
chars
[i
] = chars
[j
];
chars
[j
] = temp
;
}
}
}
System
.out
.println((int)chars
[5]);
}
转载请注明原文地址:https://tech.qufami.com/read-18291.html