-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (65 loc) · 2.52 KB
/
main.cpp
File metadata and controls
73 lines (65 loc) · 2.52 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
#include <iostream>
#include <vector>
#include <time.h>
#include "bubblesort.h"
#include "selectionsort.h"
#include "insertionsort.h"
#include "quicksort.h"
#include "helper.h"
#include "mergesort.h"
using namespace std;
int main(){
int userInput;
int arraySize;
while(true){
clock_t start, end;
std::cout << "\nType the array size: ";
std::cin >> arraySize;
int *arrVals = new int[arraySize];
createArray(arrVals, arraySize);
helperPrint(arrVals, arraySize);
std::cout << "\n[1] Insertion Sort\n[2] Bubble Sort\n[3] Selection Sort\nSELECT AN OPTION:";
std::cin >> userInput;
switch(userInput){
case 1:
start = clock();
insertionsort(arrVals, arraySize);
end = clock();
helperPrint(arrVals, arraySize);
std::cout << "\nExecution time: " << double(end-start)/CLOCKS_PER_SEC << "\n";
break;
case 2:
start = clock();
bubblesort(arrVals, arraySize);
end = clock();
helperPrint(arrVals, arraySize);
std::cout << "\nExecution time: " << double(end-start)/CLOCKS_PER_SEC << "\n";
break;
case 3:
start = clock();
selectionsort(arrVals, arraySize);
end = clock();
helperPrint(arrVals, arraySize);
std::cout << "\nExecution time: " << double(end-start)/CLOCKS_PER_SEC << "\n";
break;
// case 4:
// start = clock();
// quicksort(arrVals, 0, arraySize-1);
// helperPrint(arrVals, arraySize);
// end = clock();
// std::cout << "\nExecution time: " << double(end-start)/CLOCKS_PER_SEC << "\n";
// break;
// case 5:
// start = clock();
// mergesort(arrVals, 0, arraySize-1);
// helperPrint(arrVals, arraySize);
// end = clock();
// std::cout << "\nExecution time: " << double(end-start)/CLOCKS_PER_SEC << "\n";
// break;
// default:
// return 0;
}
delete arrVals;
}
return 0;
}