-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
56 lines (44 loc) · 1.44 KB
/
main.go
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
package main
import (
"Algorithm/Sort"
"fmt"
"strings"
)
func main() {
array:=[]int{1, 5, 3, 6, 10, 55, 9, 2, 87, 12, 34, 75, 33, 47,-1,16,-22,122,108,54,-14,102,96,22}
fmt.Println("希尔排序")
Sort.ShellSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
fmt.Println("插入排序")
Sort.InsertSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
fmt.Println("选择排序")
Sort.SelectionSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
fmt.Println("直接插入排序")
Sort.StraightInsertionSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
fmt.Println("冒泡排序算法")
Sort.BubbleSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
fmt.Println("快速排序")
Sort.QuickSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
fmt.Println("堆排序")
Sort.HeapSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
fmt.Println("归并排序")
Sort.MergeSort(array)
fmt.Println(ArrayToString(array))
fmt.Println("-------------------------------------")
}
func ArrayToString(arr interface{})string {
return strings.Replace(strings.Trim(fmt.Sprint(arr), "[]"), " ", ",", -1)
}