满意答案
fjshxhr
2020.04.10
采纳率:49% 等级:9
已帮助:416人
#include
#include
#define NUM 10
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//冒泡排序算法
//基本思想:比较相邻的两个数,如果前者比后者大,则进行交换。每一轮排序结束,选出一个未排序中最大的数放到数组后面。
void bubbleSort(int *arr, int n) {
int i,j;
for (i = 0; i
for (j = 0; j < n - i - 1; j++) {
//如果前面的数比后面大,进行交换
if (arr[j] > arr[j + 1]) { </