-
Notifications
You must be signed in to change notification settings - Fork 8
/
example.php
62 lines (57 loc) · 2.14 KB
/
example.php
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
<?php
/**
* Created by PhpStorm.
* User: frowhy
* Date: 2017/4/4
* Time: 04:22
*
*_______________%%%%%%%%%_______________________
*______________%%%%%%%%%%%%_____________________
*______________%%%%%%%%%%%%%____________________
*_____________%%__%%%%%%%%%%%___________________
*____________%%%__%%%%%%_%%%%%__________________
*____________%%%_%%%%%%%___%%%%_________________
*___________%%%__%%%%%%%%%%_%%%%________________
*__________%%%%__%%%%%%%%%%%_%%%%_______________
*________%%%%%___%%%%%%%%%%%__%%%%%_____________
*_______%%%%%%___%%%_%%%%%%%%___%%%%%___________
*_______%%%%%___%%%___%%%%%%%%___%%%%%%_________
*______%%%%%%___%%%__%%%%%%%%%%%___%%%%%%_______
*_____%%%%%%___%%%%_%%%%%%%%%%%%%%__%%%%%%______
*____%%%%%%%__%%%%%%%%%%%%%%%%%%%%%_%%%%%%%_____
*____%%%%%%%__%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%____
*___%%%%%%%__%%%%%%_%%%%%%%%%%%%%%%%%_%%%%%%%___
*___%%%%%%%__%%%%%%_%%%%%%_%%%%%%%%%___%%%%%%___
*___%%%%%%%____%%__%%%%%%___%%%%%%_____%%%%%%___
*___%%%%%%%________%%%%%%____%%%%%_____%%%%%____
*____%%%%%%________%%%%%_____%%%%%_____%%%%_____
*_____%%%%%________%%%%______%%%%%_____%%%______
*______%%%%%______;%%%________%%%______%________
*________%%_______%%%%________%%%%______________
*/
use Frowhy\Algorithm\Algorithm;
require_once __DIR__ . '/vendor/autoload.php';
$total = 20;
$arr = [];
for ($i = 0; $i < $total; $i++) {
$arr[] = rand(-10000, 10000);
}
$quickSort = Algorithm::quickSort($arr);
$bubbleSort = Algorithm::bubbleSort($arr);
$selectionSort = Algorithm::selectionSort($arr);
$insertionSort = Algorithm::insertionSort($arr);
$shellSort = Algorithm::shellSort($arr);
$mergeSort = Algorithm::mergeSort($arr);
$countingSort = Algorithm::countingSort($arr);
$heapSort = Algorithm::heapSort($arr);
print_r([
'原数组' => $arr,
'快速排序' => $quickSort,
'冒泡排序' => $bubbleSort,
'选择排序' => $selectionSort,
'插值排序' => $insertionSort,
'希尔排序' => $shellSort,
'归并排序' => $mergeSort,
'计算排序' => $countingSort,
'堆排序' => $heapSort,
]);