文章没有解释和代码注释,代码经改进,做成了好理解,关键是好记忆的方式进行书写。用于自己进行查阅
#include <stdio.h>void sort(int arr[] ,int left ,int right)
{if(left > right)return;int i = left;int j = right;int get = arr[right];while(i < j){while(i < j && arr[i] <= get )i++;arr[j] = arr[i];while(i < j && arr[j] >= get)j--;arr[i] = arr[j];}arr[j] = get; sort(arr,left,i- 1);sort(arr,i+1,right);}
int main()
{int arr1[10] = {1,2,3,4,6,7,8,9,5,10};sort(arr1,0,9);for(int i = 0;i < 10; i++)printf("%d ",arr1[i]);return 0;
}