您当前的位置: 首页 > 

ZhangJiQun&MXP

暂无认证

  • 2浏览

    0关注

    1187博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

快速排序

ZhangJiQun&MXP 发布时间:2018-11-28 18:02:35 ,浏览量:2

#include using namespace std;   //快速排序,在子函数中,数组已被改变 void quick_sort(int *a, int left, int right) //left和right为索引值 {     int temp; //存储每次选定的基准数(从最左侧选基准数)     int t;     int initial=left;     int end=right;     temp=a[left];       //***必须有这一部分***//     if (left>right)  //因为在递归过程中有减1加1的情况,当其越界时,直接return,不返回任何值,即结束当前程序块         return;          while(left!=right)  //此时左右index在移动中,若left==right,则跳出循环,将基数归位     {         while(a[right]>=temp && left

关注
打赏
1665659684
查看更多评论
立即登录/注册

微信扫码登录

0.0426s