import java.util.Scanner;
import java.lang.Math;
public class Main {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
String [] input = sc.nextLine().split(" ");
int n = Integer.parseInt(input[0]);
int k = Integer.parseInt(input[1]);
String [] input2 = new String [n];
for (int i = 0; i < n; i++) {
input2 [i] = sc.nextLine();
}
for (int j = 0; j < n - 1; j++) {
k--;
for (int s = 0; s < n - 1 - j; s++) {
String temp;
if (input2[s].compareTo(input2[s + 1]) > 0) {
temp = input2[s];
input2[s] = input2[s + 1];
input2[s + 1] = temp;
}
}
if (k == 0) {
for (int h = 0; h < n; h++) {
System.out.println(input2[h]);
}
}
}
}
}
7-30 字符串的冒泡排序 (20 分)
最新推荐文章于 2023-02-27 23:56:06 发布