编程题:30
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int K = scanner.nextInt();
scanner.nextLine();
String[] strings = new String[N];
for (int i = 0; i < N; i++) {
strings[i] = scanner.nextLine();
}
for (int i = 0; i < K; i++) {
for (int j = 0; j < N - 1 - i; j++) {
if (strings[j].compareTo(strings[j + 1]) > 0) {
String temp = strings[j];
strings[j] = strings[j + 1];
strings[j + 1] = temp;
}
}
}
for (String s : strings) {
System.out.println(s);
}
}
}
浙公网安备 33010602011771号