-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
74 lines (51 loc) · 1.77 KB
/
main.c
File metadata and controls
74 lines (51 loc) · 1.77 KB
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
#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-msc50-cpp"
#include <stdio.h>
#include "sort.h"
#include "myPrinter.h"
int main() {
int numbers[] = {1, 2, 3, 4, 5, 15, 6, 6, 17, 7, 8, 9, 10, 14, 19, 9, 16, 3, 5, 12, 13, 2};
int n = sizeof(numbers) / sizeof(numbers[0]);
newline(1);
bool didItSort=bogoSort(numbers, n);
if (didItSort) {
randomiseArray(n, numbers);
printArray(n, numbers);
printArrow(n);
printArray(n, numbers);
newline(2);
} else
puts("bogo sort failed a million tries");
puts("gnome sort:");
printSortFunction(numbers, n, gnomeSort);
puts("bead sort:");
printSortFunction(numbers, n, beadSort);
puts("bubble sort:");
printSortFunction(numbers, n, introSort);
puts("insertion sort using linked list:");
printSortFunction(numbers, n, insertionSortUsingLinkedLists);
puts("quick sort:");
printSortFunction(numbers, n, quickSort);
puts("merge sort:(Bottom->Up):");
printSortFunction(numbers, n, mergeSort);
puts("merge sort(Top->Down):");
printSortFunction(numbers, n, TopDownMergeSort);
puts("heap sort:");
printSortFunction(numbers, n, heapSort);
puts("insertion sort:");
printSortFunction(numbers, n, insertionSort);
puts("intro sort:");
printSortFunction(numbers, n, introSort);
puts("tim sort:");
printSortFunction(numbers, n, timSort);
puts("selection sort:");
printSortFunction(numbers, n, selectionSort);
puts("shell sort:");
printSortFunction(numbers, n, shellSort);
puts("tree sort:");
printSortFunction(numbers, n, treeSort);
puts("cocktail shaker sort:");
printSortFunction(numbers, n, cocktailShakerSort);
return 0;
}
#pragma clang diagnostic pop