您的位置:首页 > 编程语言 > C语言/C++

用c语言指针实现给整形数组冒泡排序

2016-06-23 16:18 309 查看
#include<stdio.h>

void reverse(const int *start,const int *end)
{
int *tstart = start;
while (start != end)
{
int *left = tstart;
while (left != end)
{
if (*left > *(left + 1))
{
*left = *left^*(left + 1);
*(left + 1) = *left^*(left + 1);
*left = *left ^ *(left + 1);
left++;
}
else
left++;
}
start++;
}
}

int main()
{
int a[] = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
int len = sizeof(a) / sizeof(a[0]);
reverse(a, a + len - 1);
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: