首页 > 编程语言 > 详细

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

时间:2016-01-16 07:40:26      阅读:298      评论:0      收藏:0      [点我收藏+]
#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;
}


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

原文:http://lzd1995.blog.51cto.com/10973198/1735480

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!