NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
~~~ void swap(int *a,int *b){ int temp; temp = *a; *a = *b; *b = temp; } int partition(int *a,int p,int r){ int x = a[r]; int i = p-1; for(int j=p;j<r;j++){ if(a[j]<=x){ i++; swap(&a[i],&a[j]); } } swap(&a[i+1],&a[r]); return i+1; } void quickSort(int *a,int p,int r){ if(p<r){ int q = partition(a,p,r); quickSort(a,p,q-1); quickSort(a,q+1,r); } } ~~~