-
Notifications
You must be signed in to change notification settings - Fork 0
/
SortedTest.h
80 lines (64 loc) · 1.5 KB
/
SortedTest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// Created by ThinkPad on 2019/12/10.
//
#ifndef WORKPLACE_SORTEDTEST_H
#define WORKPLACE_SORTEDTEST_H
#include <iostream>
#include "CSorted.h"
using std::cout;
using std::endl;
template<class T>
void visit(T *arr, int n) {
for (int i = 0; i < n; ++i) {
cout<<arr[i]<<" ";
}
cout<<endl;
}
void ShellSortTest() {
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
ShellSort(arr, 10, lt);
visit(arr,10);
}
void InsertSortTest() {
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
InsertSort(arr, 10, lt);
visit(arr,10);
}
void BinaryInsertSortTest(){
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
BinaryInsertSort(arr,10,lt);
visit(arr,10);
}
void BubbleSortTest(){
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
BubbleSort(arr,10,lt);
visit(arr,10);
}
void QuickSortTest1(){
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
QuickSort1(arr,0,10,lt);
visit(arr,10);
}
void QuickSortTest2(){
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
QuickSort2(arr,0,10,lt);
visit(arr,10);
}
void SelectSortTest() {
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
SelectSort(arr,10,lt);
visit(arr,10);
}
void MergeSortTest() {
int arr[10] = {8, 4, 3, 2, 1, 9, 7, 5, 10, 6};
int ans[10];
initArr(ans,10);
MergeSort(arr,ans,0,10,lt);
visit(ans,10);
}
void RadixSortTest(){
int arr[10] = {520, 505, 321, 21, 71, 129, 708, 524, 100, 6};
RadixSort(arr,10);
visit(arr,10);
}
#endif //WORKPLACE_SORTEDTEST_H