Пример #1
0
int main()
{
	//待排数据输入方式:
		/*int N = 0;
		cout << "排序数据个数:\n";
		cin >> N;
		int* A = new int[N];
		cout << "请输入待排序的数据:\n";
		for (int i = 0; i < N; i++)
		{
		cin >> A[i];
		}*/
	//数据直接给定	
		int B[N] = { 1, 6, 3, 5, 2, 4 };
		int C[13] = { 54, 35, 48, 36, 27, 12, 44, 44, 8, 14, 26, 17, 2 };
		int* A = C;

	//从文件中读取,大量数据,计算时间复杂度
		
	printResult("待排原始数据:", C, N);

	BubbleSort bubble;
	bubble.bubbleSort(A,N);
	printResult("bubbleSort", A, N);

	SelectionSort select;
	select.selectionSort(A, N);
	printResult("selectSort", A, N);

	InsertionSort insert;
	insert.insertionSort(A, N);
	printResult("InsetSort", A, N);

	MergeSort merge;
	merge.mergeSort(A, N);
	printResult("MergeSort", A, N);

	QuickSort qucik;
	qucik.quickSort(A, N);
	printResult("QucikSort",A,N);

	QuickSort2 qucik2;
	qucik2.quickSort(A, N);
	printResult("QucikSort2", A, N);

	HeapSort heap;
	heap.heapSort(A, N);
	printResult("heapSort", A, N);

	HeapSort2 heap2;
	heap2.heapSort(A, N);
	printResult("heapSort2", A, N);


	ShellSort shell;
	shell.shellSort(A,N);
	printResult("shellSort", A, N);

	return 0;
}
int main() {
  int array[] = {4, 8, 23, 1, 5, 9, 12, 0};
  HeapSort<int> h = HeapSort<int>(array, 8);
  h.heapSort();

  for (int i=0; i<8; i++) {
    cout << array[i] << " ";
  }
  cout << endl;

  return 0;
}