自定义函数快速排序

include “stdio.h”

void quick_sort(int *a, int n){

for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++){
    if (a[i] > a[j])
    {
        int temp= a[i];
        a[i] = a[j];
        a[j] = temp;
    }
}

}
int main(){
int a [] = { 1, 6, 5, 4, 5, 3, 2, 5, 4 };
quick_sort(a, 9);
int i;
for (i = 0; i < 9; i++){
printf(“%d\n”,a[i]);
}
system(“pause”);
return 0;
}

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_42664961/article/details/82349722