炉石暗影打击可以打脸?:大家帮帮我啊,精通C的朋友帮我编一下这题啊

来源:百度文库 编辑:高校问答 时间:2024/04/26 07:32:06
编程:在主函数中输入5个字符串,用另一函数对它们进行排序,然后在主函数中输出排好序的字符串(用字符数组存储字符串,采用冒泡排序法或选择排序法

public void bubbleSort(int a[]) { //数组的冒泡排序
int n = a.length;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++) {
if (a[j] > a[j + 1]) {
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
}

这种题书上就有的