题解 | #图片整理#
图片整理
https://www.nowcoder.com/practice/2de4127fda5e46858aa85d254af43941
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
String test = in.nextLine();
char[] ch = test.toCharArray();
for (int i = 0; i < ch.length - 1; i++) {
for (int j = 0; j < ch.length - i - 1; j++) {
if (ch[j] > ch[j + 1]) {
char a = ch[j];
ch[j] = ch[j + 1];
ch[j + 1] = a;
}
}
}
System.out.println(ch);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
String test = in.nextLine();
char[] ch = test.toCharArray();
for (int i = 0; i < ch.length - 1; i++) {
for (int j = 0; j < ch.length - i - 1; j++) {
if (ch[j] > ch[j + 1]) {
char a = ch[j];
ch[j] = ch[j + 1];
ch[j + 1] = a;
}
}
}
System.out.println(ch);
}
}