-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
96 lines (91 loc) · 2.28 KB
/
main.cpp
File metadata and controls
96 lines (91 loc) · 2.28 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
*/
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
// ---------------------------
// Sort Functions
// ---------------------------
#include "bubble-Sort.h"
#include "selection-Sort.h"
#include "insertion-Sort.h"
#include "binary_insertion-Sort.h"
#include "merge-Sort.h"
//Prototipes
void printArray(long long int arr[], int size);
int main()
{
int option = 1, num_len;
do
{
printf("Enter the method by which your array should be ordered\n");
printf("1 -- Bubble Sort\n");
printf("2 -- Selection Sort\n");
printf("3 -- Insertion Sort\n");
printf("4 -- GCC Sort\n");
printf("5 -- BinaryInsertion Sort\n");
printf("6 -- Merge Sort\n");
printf("\n0 -- Finish the applicattion\n");
cin >> option;
if (option == 0)
{
exit(0);
}
printf("How many numbers array will have?\n");
cin >> num_len;
long long int arr[num_len];
printf("Enter the numbers\n");
for (int i = 0; i < num_len; i++)
{
cin >> arr[i];
}
// cout << endl;
switch (option)
{
case 1:
bubbleSort(arr, num_len);
printArray(arr, num_len);
break;
case 2:
selectionSort(arr, num_len);
printArray(arr, num_len);
break;
case 3:
insertionSort(arr, num_len);
printArray(arr, num_len);
break;
case 4:
sort(arr, arr + num_len);
printArray(arr, num_len);
break;
case 5:
insertionSort2(arr, num_len);
printArray(arr, num_len);
break;
case 6:
mergeSort(arr, 0, num_len - 1);
printArray(arr, num_len);
break;
case 0:
printf("See u, thanks for coming!!!\n");
break;
default:
printf("Please enter a valid option\n");
break;
}
} while (option != 0);
return 0;
}
/* Function to print an array */
void printArray(long long int arr[], int size)
{
int i;
printf("\n");
cout << "Array ordered: ";
for (i = 0; i < size; i++)
{
cout << arr[i] << " ";
}
cout << endl
<< endl;
}