码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2016-01-16 07:42:40      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:c语言学习

#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语言指针实现给整形数组冒泡排序

标签:c语言学习

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!