📄 exercise7_11.java
字号:
public class Exercise7_11 { public static void main(String args[]) { System.out.println(sort("abcABDs")); } public static String sort(String s) { StringBuffer buffer = new StringBuffer(s); char currentMax; int currentMaxIndex; for (int i=buffer.length() - 1; i >= 1; i--) { // Find the maximum in the buffer[0..i] currentMax = buffer.charAt(i); currentMaxIndex = i; for (int j = i - 1; j >= 0; j--) { if (currentMax < buffer.charAt(j)) { currentMax = buffer.charAt(j); currentMaxIndex = j; } } // Swap buffer.charAt(i) with buffer[currentMaxIndex] if necessary; if (currentMaxIndex != i) { buffer.setCharAt(currentMaxIndex, buffer.charAt(i)); buffer.setCharAt(i, currentMax); } } return buffer.toString(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -