当前位置: 首页 > wzjs >正文

延吉网站开发公司有哪些蓝希菏泽网站建设

延吉网站开发公司有哪些,蓝希菏泽网站建设,wordpress进不来后台,360网页怎么制作思路 partition方法将整个区间分为两部分,一部分比pivot小,一部分比pivot大, i表示,小于等于pivot的下标,j表示当前遍历到哪一个元素了,如果发现当前元素j小于等于pivot,i,在i1的位…

思路

partition方法将整个区间分为两部分,一部分比pivot小,一部分比pivot大,
i表示,小于等于pivot的下标,j表示当前遍历到哪一个元素了,如果发现当前元素j小于等于pivot,i++,在i+1的位置和 j 交换位置,最后还要将pivot放在i + 1的位置,也返回i + 1,此时 数组被分成了两部分,pivot左边的,都比pivot小,右边的都比pivot大

代码


public class QuickSort {public static void quickSort(int[] arr, int low, int high){// low 等于 high时,不需要排序了, 左闭右闭的关系if(low < high){int pivotIndex = partition(arr, low, high);quickSort(arr, low, pivotIndex - 1);quickSort(arr, pivotIndex+1, high);}}private static int partition(int[] arr, int low, int high){int pivot = arr[high];int i = low - 1;for(int j = low; j < high; j++){if(arr[j] <= pivot){i++;int temp = arr[i];arr[i] = arr[j];arr[j] = temp;}}int temp = arr[i+1];arr[i + 1] = arr[high];arr[high] = temp;return  i + 1;}public static void main(String[] args) {int []arr = {10, 7, 8, 9, 1, 5};System.out.println("排序前:");for(int num: arr){System.out.print(num + " ");}quickSort(arr, 0, arr.length - 1);System.out.println("\n排序后: ");for(int num: arr){System.out.print(num + " ");}}}

文章转载自:

http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://00000000.Lbxhy.cn
http://www.dtcms.com/wzjs/619923.html

相关文章:

  • 苏州网站建设书生商友建设网站招聘
  • 网站做优化的必要性外贸网站设计注意事项
  • 优化科技seo点击排名源码
  • 厦网站建设培训学校空壳网站清理通知
  • 阿里云可以做网站如何做营销活动
  • 快速网站优化服务公众号seo排名优化
  • 网站建设优化服务新闻连云港权威网站优化服务
  • 毅冰做外贸是哪个网站在手机上怎么做微电影网站吗
  • 金阊seo网站优化软件邢台网站优化公司
  • 网站建设肆金手指排名2武昌网站建设哪家便宜
  • wordpress站长统计插件手机上那个网站做农产品推广比较好
  • 网站设计公司合肥vi形象设计企业vi设计公司
  • led网站模板软件开发外包公司哪个好
  • 手机怎么访问wap网站重庆网站制作公司电话
  • 关于医院网站建设的通知企业官方网站的作用
  • 邯郸做seo网站优化跨境电商有哪些平台
  • 陶瓷 网站模板wordpress有中文版没
  • 常州哪些网站公司做的好处自媒体平台有哪些赚钱
  • 有没有做黑市网站大气装饰公司网站源码
  • 网站建设的空间选择网站建设要求
  • 个人怎么做一个网站成都建设局官网
  • 网站建设与优化及覆盖率方案江苏省建设网站
  • 简述网站与网页的区别广电基础设施建设官方网站
  • 线上网站怎么做wordpress弹窗网页
  • wordpress建的网站打开太慢网页在线代理
  • 湖州做网站公司有那几家网站备案有幕布
  • 网站升级中模板自己有网站怎么优化
  • 哪个网站帮别人做pptwordpress 收费版
  • 公司的网站建设公司WordPress写文章本地上传
  • 网站的pdf目录怎么做的河源公司做网站