-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.cpp
65 lines (43 loc) · 1.17 KB
/
main.cpp
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
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include "Timer.h"
#include "MyArray.h"
using namespace std;
int main()
{
//Enter the size of the array
int array_size = 0;
cout << "Enter the size of the array: ";
cin >> array_size;
//Choose how it is sorted (crescent, decrescent, randomly)
char sorting;
cout << "\nChoose how it is sorted:\n"
<< "1. Crescent\n"
<< "2. Decrescent\n"
<< "3. Random\n"
<< "-> ";
cin >> sorting;
//Choose the sorting algorithm
char algorithm;
cout << "\nChoose the sorting algorithm:\n"
<< "1. Bubble Sort\n"
<< "2. Insertion Sort\n"
<< "3. Selection Sort\n"
<< "4. Quick Sort\n"
<< "5. Merge Sort\n"
<< "6. Heap Sort\n"
<< "7. Radix Sort\n"
<< "8. Pigeonhole Sort\n"
<< "-> ";
cin >> algorithm;
//Generate array
MyArray arr(array_size, sorting, algorithm);
//Sort and calculate time spent on sorting
Timer timer;
timer.start();
arr.sort_array();
timer.stop();
cout << "\nTotal time: " << timer.total() << " ms" << endl;
return 0;
}