后端
·2023-03-14#快速排序(位运算交换版)
#Java# #算法# [得意]
public static void quick_sort02(int[] p, int L, int R) {
if (L >= R) return;
int i = L - 1;
int j = R 1;
int x = p[L R >> 1];
while (i < j) {
do i ; while (p[i] < x);
do j--; while (p[j] > x);
if (i < j) {
//int t;
//t = p[j];
//p[j] = p[i];
//p[i] = t;
//位运算交换数字
p[j] ^= p[i];
p[i] = p[j] ^ p[i];
p[j] = p[j] ^ p[i];
}
}
quick_sort02(p, L, j);
quick_sort02(p, j 1, R);
}
8
0
分享
操作
评论
相关内容
0个评论
全部评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
