ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

四种排序的程序实现

2021-02-04 18:04:29  阅读:163  来源: 互联网

标签:begin end PrintArray 程序实现 void int sizeof 排序 四种


**

排序****

1.插入排序(直接插入排序,希尔排序)
2.选择排序(选择排序,堆排序)
3.交换排序(冒泡排序,快速排序)
4.归并排序(归并排序)

1直接插入排序

Sort.c

#include "Sort.h"

//插入排序
void InsertSort(int*a, int n)
{
	assert(a);
	
	for (int i = 0; i < n - 1; ++i)
	{
		//把end+1的数据插入[0.end]的有序区间
		int end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (tmp < a[end])
			{
				a[end + 1] = a[end];
				--end;
			}
			else
			{
				break;
			}
		}
		a[end + 1] = tmp;
	}
}

	
```c
Sort.h
#pragma once 
#include <stdio.h>
#include <assert.h>

//插入排序
void InsertSort(int*a, int n);

Test.c

#include "Sort.h"

void PrintArray(int*a, int n)
{
	for (int i = 0; i < n; ++i)
	{
		printf("%d", a[i]);
	}
	printf("\n");
}

void TestInsertSort()
{
	int a[] = { 3, 1, 4, 1, 7, 9, 8, 2, 0, 5 };
	PrintArray(a, sizeof(a) / sizeof(int));
	InsertSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));


}

int main()
{
	TestInsertSort();

	return 0;
}

在这里插入图片描述

2.希尔排序
(1)预排序(先把数组派到接近有序)
(2)再直接插入排序

gap越大,前面大的数据可以越快到后面,后面小的数,可以越快到前面。但是gap越大,越不接近有序。
gap越小越接近有序。若gap==1就相当于直接插入排序,就有序了。

```c
Sort.c`



#include "Sort.h"

void PrintArray(int*a, int n)
{
	for (int i = 0; i < n; ++i)
	{
		printf("%d", a[i]);
	}
	printf("\n");
}

//插入排序
void InsertSort(int*a, int n)
{
	assert(a);
	
	for (int i = 0; i < n - 1; ++i)
	{
		//把end+1的数据插入[0.end]的有序区间
		int end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (tmp < a[end])
			{
				a[end + 1] = a[end];
				--end;
			}
			else
			{
				break;
			}
		}
		a[end + 1] = tmp;
	}
}

	


//希尔排序
void ShellSort(int* a, int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;//保证最后一次一定是1
		for (int i = 0; i < n - gap; ++i)
		{
			int end = i;
			int tmp = a[end + gap];
			while (end >= 0)
			{
				if (tmp < a[end])
				{
					a[end + gap] = a[end];
					end -= gap;
				}
				else
				{
					break;
				}

			}
			a[end + gap] = tmp;
		}
		//PrintArray(a, n);
	}
}

Sort.h

#pragma once 
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>


//排序实现的接口

void PrintArray(int*a, int n);

//插入排序
void InsertSort(int*a, int n);


//希尔排序
void ShellSort(int*a, int n);


Test.c
#include "Sort.h"

void TestInsertSort()
{
	int a[] = { 3, 1, 4, 1, 7, 9, 8, 2, 0, 5 };
	PrintArray(a, sizeof(a) / sizeof(int));
	InsertSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));


}

void TestShellSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	ShellSort(a, sizeof(a) / sizeof(int));
	//PrintArray(a, sizeof(a) / sizeof(int));
}

void TestOP()
{
	srand(time(0));
	const int N = 10000;
	int* a1 = (int*)malloc(sizeof(int)*N);
	int* a2 = (int*)malloc(sizeof(int)*N);
	int* a3 = (int*)malloc(sizeof(int)*N);
	int* a4 = (int*)malloc(sizeof(int)*N);
	int* a5 = (int*)malloc(sizeof(int)*N);
	int* a6 = (int*)malloc(sizeof(int)*N);


	for (int i = 0; i < N; ++i)
	{
		a1[i] = rand();
		a2[i] = a1[i];
		a3[i] = a1[i];
		a4[i] = a1[i];
		a5[i] = a1[i];
		a6[i] = a1[i];
	}
	int begin1 = clock();
	InsertSort(a1, N);
	int end1 = clock();

	int begin2 = clock();
	ShellSort(a2, N);
	int end2 = clock();



	printf("InsertSort:%d\n", end1 - begin1);
	printf("ShellSort:%d\n", end2 - begin2);

	free(a1);
	free(a2);
	free(a3);
	free(a4);
	free(a5);
	free(a6);

}

int main()
{
	//TestInsertSort();
	//TestShellSort();
	TestOP();

	return 0;
}

在这里插入图片描述

2.选择排序

Sort.c
#include "Sort.h"

void PrintArray(int*a, int n)
{
	for (int i = 0; i < n; ++i)
	{
		printf("%d", a[i]);
	}
	printf("\n");
}

//插入排序
void InsertSort(int*a, int n)
{
	assert(a);
	
	for (int i = 0; i < n - 1; ++i)
	{
		//把end+1的数据插入[0.end]的有序区间
		int end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (tmp < a[end])
			{
				a[end + 1] = a[end];
				--end;
			}
			else
			{
				break;
			}
		}
		a[end + 1] = tmp;
	}
}

	


//希尔排序
void ShellSort(int* a, int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;//保证最后一次一定是1
		for (int i = 0; i < n - gap; ++i)
		{
			int end = i;
			int tmp = a[end + gap];
			while (end >= 0)
			{
				if (tmp < a[end])
				{
					a[end + gap] = a[end];
					end -= gap;
				}
				else
				{
					break;
				}

			}
			a[end + gap] = tmp;
		}
		//PrintArray(a, n);
	}
}

void Swap(int*p1, int*p2)
{
	int tmp = *p1;
	*p1 = *p2;
	*p2 = tmp;
}
//选择排序
void SelectSort(int*a, int n)
{
	assert(a);

	int begin = 0, end = n - 1;
	while (begin < end)
	{
		//在[begin,end]之间找出最小数和最大的数的下标
		int mini, maxi;
		mini = maxi = begin;
		for (int i = begin + 1; i <= end; ++i)
		{
			if (a[i]>a[maxi])
			{
				maxi = i;
			}
			if (a[i] < a[mini])
			{
				mini = i;
			}
		}
		Swap(&a[begin], &a[mini]);
		//如果max和begin位置重叠,则maxi的位置需要修正
		if (begin == maxi)
		{
			maxi = mini;
		}

		Swap(&a[end], &a[maxi]);

		++begin;
		--end;
	}
}


Sort.h
#pragma once 
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>


//排序实现的接口

void PrintArray(int*a, int n);

//插入排序
void InsertSort(int*a, int n);


//希尔排序
void ShellSort(int*a, int n);

Test.c
#include "Sort.h"

void TestInsertSort()
{
	int a[] = { 3, 1, 4, 1, 7, 9, 8, 2, 0, 5 };
	PrintArray(a, sizeof(a) / sizeof(int));
	InsertSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));


}

void TestShellSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	ShellSort(a, sizeof(a) / sizeof(int));
	//PrintArray(a, sizeof(a) / sizeof(int));
}

void TestSelectSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	SelectSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}

void TestOP()
{
	srand(time(0));
	const int N = 10000;
	int* a1 = (int*)malloc(sizeof(int)*N);
	int* a2 = (int*)malloc(sizeof(int)*N);
	int* a3 = (int*)malloc(sizeof(int)*N);
	int* a4 = (int*)malloc(sizeof(int)*N);
	int* a5 = (int*)malloc(sizeof(int)*N);
	int* a6 = (int*)malloc(sizeof(int)*N);


	for (int i = 0; i < N; ++i)
	{
		a1[i] = rand();
		a2[i] = a1[i];
		a3[i] = a1[i];
		a4[i] = a1[i];
		a5[i] = a1[i];
		a6[i] = a1[i];
	}
	int begin1 = clock();
	InsertSort(a1, N);
	int end1 = clock();

	int begin2 = clock();
	ShellSort(a2, N);
	int end2 = clock();



	printf("InsertSort:%d\n", end1 - begin1);
	printf("ShellSort:%d\n", end2 - begin2);

	free(a1);
	free(a2);
	free(a3);
	free(a4);
	free(a5);
	free(a6);

}

int main()
{
	//TestInsertSort();
	//TestShellSort();
	TestSelectSort();
	//TestOP();

	return 0;
}

在这里插入图片描述

2.堆排序

Sort.c
#include "Sort.h"

void PrintArray(int*a, int n)
{
	for (int i = 0; i < n; ++i)
	{
		printf("%d", a[i]);
	}
	printf("\n");
}

//插入排序
void InsertSort(int*a, int n)
{
	assert(a);
	
	for (int i = 0; i < n - 1; ++i)
	{
		//把end+1的数据插入[0.end]的有序区间
		int end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (tmp < a[end])
			{
				a[end + 1] = a[end];
				--end;
			}
			else
			{
				break;
			}
		}
		a[end + 1] = tmp;
	}
}

	


//希尔排序
void ShellSort(int* a, int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;//保证最后一次一定是1
		for (int i = 0; i < n - gap; ++i)
		{
			int end = i;
			int tmp = a[end + gap];
			while (end >= 0)
			{
				if (tmp < a[end])
				{
					a[end + gap] = a[end];
					end -= gap;
				}
				else
				{
					break;
				}

			}
			a[end + gap] = tmp;
		}
		//PrintArray(a, n);
	}
}

void Swap(int*p1, int*p2)
{
	int tmp = *p1;
	*p1 = *p2;
	*p2 = tmp;
}
//选择排序
void SelectSort(int*a, int n)
{
	assert(a);

	int begin = 0, end = n - 1;
	while (begin < end)
	{
		//在[begin,end]之间找出最小数和最大的数的下标
		int mini, maxi;
		mini = maxi = begin;
		for (int i = begin + 1; i <= end; ++i)
		{
			if (a[i]>a[maxi])
			{
				maxi = i;
			}
			if (a[i] < a[mini])
			{
				mini = i;
			}
		}
		Swap(&a[begin], &a[mini]);
		//如果max和begin位置重叠,则maxi的位置需要修正
		if (begin == maxi)
		{
			maxi = mini;
		}

		Swap(&a[end], &a[maxi]);

		++begin;
		--end;
	}
}

//堆排序
void AdjustDwon(int* a, int n, int root)
{
	int parent = root;
	int child = parent * 2 + 1;
	while (child < n)
	{
		if (child + 1 < n&&a[child + 1] > a[child])
		{
			++child;
		}
		if (a[child] > a[parent])
		{
			Swap(&a[child], &a[parent]);
			parent = child;
			child = parent * 2 + 1;
		
		}
		else
		{
			break;
		}
	}
}
void HeapSort(int* a, int n)
{
	//堆升序,建大堆还是小堆?
	for (int i = (n - 1 - 1) / 2; i >= 0; --i)
	{
		AdjustDwon(a, n, i);
	}
	int end = n - 1;
	while (end > 0)
	{
		Swap(&a[0], &a[end]);
		AdjustDwon(a, end, 0);
		--end;
	}
}

Sort.h
#pragma once 
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>


//排序实现的接口

void PrintArray(int*a, int n);

//插入排序
void InsertSort(int*a, int n);


//希尔排序
void ShellSort(int*a, int n);

Test.c
#include "Sort.h"

void TestInsertSort()
{
	int a[] = { 3, 1, 4, 1, 7, 9, 8, 2, 0, 5 };
	PrintArray(a, sizeof(a) / sizeof(int));
	InsertSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));


}

void TestShellSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	ShellSort(a, sizeof(a) / sizeof(int));
	//PrintArray(a, sizeof(a) / sizeof(int));
}

void TestSelectSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	SelectSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));

}


void TestHeapSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	HeapSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}

void TestOP()
{
	srand(time(0));
	const int N = 10000;
	int* a1 = (int*)malloc(sizeof(int)*N);
	int* a2 = (int*)malloc(sizeof(int)*N);
	int* a3 = (int*)malloc(sizeof(int)*N);
	int* a4 = (int*)malloc(sizeof(int)*N);
	int* a5 = (int*)malloc(sizeof(int)*N);
	int* a6 = (int*)malloc(sizeof(int)*N);


	for (int i = 0; i < N; ++i)
	{
		a1[i] = rand();
		a2[i] = a1[i];
		a3[i] = a1[i];
		a4[i] = a1[i];
		a5[i] = a1[i];
		a6[i] = a1[i];
	}
	int begin1 = clock();
	InsertSort(a1, N);
	int end1 = clock();

	int begin2 = clock();
	ShellSort(a2, N);
	int end2 = clock();



	printf("InsertSort:%d\n", end1 - begin1);
	printf("ShellSort:%d\n", end2 - begin2);

	free(a1);
	free(a2);
	free(a3);
	free(a4);
	free(a5);
	free(a6);

}

int main()
{
	//TestInsertSort();
	//TestShellSort();
	//TestSelectSort();
	TestHeapSort();
	//TestOP();

	return 0;
}

在这里插入图片描述
3.冒泡排序

Sort.c
void BubbleSort(int*a, int n)
{
	int end = n;
	while (end>0)
	{
		int exchange = 0;
		for (int i = 1; i < end; ++i)
		{
			if (a[i - 1]>a[i])
			{
				Swap(&a[i - 1], &a[i]);
				exchange = 1;
			}
		}
		if (exchange == 0)
		{
			break;
		}
	}
}

Test.c
void TestBubbleSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	BubbleSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}

在这里插入图片描述
3.快速排序
(1)左边比key要小,右边比key要大
(2)key放到正确的位置(最终要放的位置)
(3)选最右边的值做key,一定要让begin先走,这样相遇的位置是一个比key大的位置,反之亦然

Sort.c
//[begin,end]必须是闭区间
int PartSort(int*a, int begin, int end)
{
	int keyindex = end;
	while (begin < end)
	{
		//begin找大
		while (begin < end && a[begin] <= a[keyindex])
		{
			++begin;
		}
		//end找小
		while (begin < end && a[end] >= a[keyindex])
		{
			--end;
		}
		Swap(&a[begin], &a[end]);
	}
	Swap(&a[begin], &a[keyindex]);
	return begin;
}

void QuickSort(int*a, int left, int right)
{
	assert(a);
	if (left >= right) 
		return;

	int div = PartSort(a, left, right);

	PrintArray(a + left, right - left + 1);

	printf("[%d,%d]%d[%d,%d]\n", left, div - 1, div, div + 1, right);
	
	//[left,div-1]div[div+1,right]
	QuickSort(a, left, div - 1);
	QuickSort(a, div + 1, right);
}

Sort.h
#pragma once 
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>


//排序实现的接口

void PrintArray(int*a, int n);

//插入排序
void InsertSort(int*a, int n);


//希尔排序
void ShellSort(int*a, int n);

Test.c
#include "Sort.h"

void TestInsertSort()
{
	int a[] = { 3, 1, 4, 1, 7, 9, 8, 2, 0, 5 };
	PrintArray(a, sizeof(a) / sizeof(int));
	InsertSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));


}

void TestShellSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	ShellSort(a, sizeof(a) / sizeof(int));
	//PrintArray(a, sizeof(a) / sizeof(int));
}

void TestSelectSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	SelectSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));

}


void TestHeapSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	HeapSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}

void TestBubbleSort()
{
	int a[] = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
	PrintArray(a, sizeof(a) / sizeof(int));
	BubbleSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}

void TestQuickSort()
{
	int a[] = { 3,1,4,1,7,9,8,2,0,5 };
	PrintArray(a, sizeof(a) / sizeof(int));
	QuickSort(a,0, sizeof(a) / sizeof(int)-1);
	PrintArray(a, sizeof(a) / sizeof(int));
}
void TestOP()
{
	srand(time(0));
	const int N = 10000;
	int* a1 = (int*)malloc(sizeof(int)*N);
	int* a2 = (int*)malloc(sizeof(int)*N);
	int* a3 = (int*)malloc(sizeof(int)*N);
	int* a4 = (int*)malloc(sizeof(int)*N);
	int* a5 = (int*)malloc(sizeof(int)*N);
	int* a6 = (int*)malloc(sizeof(int)*N);


	for (int i = 0; i < N; ++i)
	{
		a1[i] = rand();
		a2[i] = a1[i];
		a3[i] = a1[i];
		a4[i] = a1[i];
		a5[i] = a1[i];
		a6[i] = a1[i];
	}
	int begin1 = clock();
	InsertSort(a1, N);
	int end1 = clock();

	int begin2 = clock();
	ShellSort(a2, N);
	int end2 = clock();



	printf("InsertSort:%d\n", end1 - begin1);
	printf("ShellSort:%d\n", end2 - begin2);

	free(a1);
	free(a2);
	free(a3);
	free(a4);
	free(a5);
	free(a6);

}

int main()
{
	//TestInsertSort();
	//TestShellSort();
	//TestSelectSort();
	//TestHeapSort();
	//TestBubbleSort();
	TestQuickSort();
	//TestOP();

	return 0;
}

在这里插入图片描述
加入三数取中,效率大大提高

{
	int mid = (begin + end) / 2;
	if (a[begin] < a[mid])
	{
		if (a[mid] < a[end])
		{
			return mid;
		}
		else if (a[begin]>a[end])
		{
			return begin;
		}
		else
		{
			return end;
		}
	}
	else{
		if (a[mid] > a[end])
		{
			return mid;
		}
		else if (a[begin]<a[end])
		{
			return begin;
		}
		else
		{
			return end; 
		}
	}
}

//[begin,end]必须是闭区间
int PartSort(int*a, int begin, int end)
{
	int midIndex = GetMidIndex(a, begin, end);
	Swap(&a[midIndex], &a[end]);

	int keyindex = end;
	while (begin < end)
	{
		//begin找大
		while (begin < end && a[begin] <= a[keyindex])
		{
			++begin;
		}
		//end找小
		while (begin < end && a[end] >= a[keyindex])
		{
			--end;
		}
		Swap(&a[begin], &a[end]);
	}
	Swap(&a[begin], &a[keyindex]);
	return begin;
}

void QuickSort(int*a, int left, int right)
{
	assert(a);
	if (left >= right) 
		return;

	int div = PartSort(a, left, right);

	PrintArray(a + left, right - left + 1);

	printf("[%d,%d]%d[%d,%d]\n", left, div - 1, div, div + 1, right);
	
	//[left,div-1]div[div+1,right]
	QuickSort(a, left, div - 1);
	QuickSort(a, div + 1, right);
}


4,归并排序
(常用于外排序,硬盘中排序,内排序,内存中排序)

Sort.c
void _MergeSort(int*a, int left, int right, int* tmp)
{
	if (left >= right)
		return;

	int mid = (left + right) / 2;
	//
	//
	_MergeSort(a, left, mid, tmp);
	_MergeSort(a, mid + 1, right, tmp);
	//
	int begin1 = left, end1 = mid;
	int begin2 = mid + 1, end2 = right;
	int index = begin1;
	while (begin1 <= end1 && begin2 <= end2)
	{
		if (a[begin1] < a[begin2])
			tmp[index++] = a[begin1++];
		else
			tmp[index++] = a[begin2++];
	}
	while (begin1 <= end1)
		tmp[index++] = a[begin1++];
	while (begin2 <= end2)
		tmp[index++] = a[begin2++];

	//把归并好的再tmp的数据再拷贝回到原数组
	for (int i = left; i <= right; ++i)
		a[i] = tmp[i];
}
//归并排序递归实现
void MergeSort(int*a, int n)
{
	assert(a);
	int* tmp = malloc(sizeof(int)*n);

	_MergeSort(a, 0, n - 1, tmp);


	free(tmp);
}
Sort.h
#pragma once 
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>


//排序实现的接口

void PrintArray(int*a, int n);

//插入排序
void InsertSort(int*a, int n);


//希尔排序
void ShellSort(int*a, int n);

//归并排序
void MergeSort(int*a, int n);

Test.c
void TestMergeSort()
{
	int a[] = { 3, 5, 4, 1, 7, 9, 8, 5, 0, 5 };
	PrintArray(a, sizeof(a) / sizeof(int));
	MergeSort(a, sizeof(a) / sizeof(int));
	PrintArray(a, sizeof(a) / sizeof(int));
}

在这里插入图片描述


标签:begin,end,PrintArray,程序实现,void,int,sizeof,排序,四种
来源: https://blog.csdn.net/weixin_46031570/article/details/113660157

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有