forked from philona/cppcodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMergeSort.cpp
More file actions
36 lines (28 loc) · 721 Bytes
/
MergeSort.cpp
File metadata and controls
36 lines (28 loc) · 721 Bytes
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
#include<bits/stdc++.h>
using namespace std;
#define debug(x){cout<<"x : "<<x<<endl;}
void printArray(int A[], int size) {
for (auto i = 0; i < size; i++)
cout << A[i] << " ";
}
void mergeSort(int array[], int const begin, int const end) {
if (begin >= end) {
return;
}
auto mid = begin + (end - begin) / 2;
}
int main() {
#ifndef ONLINE_JUDGE
//for getting input from input.txt
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int arr[] = {12, 11, 13, 5, 6, 7 };
auto arr_size = sizeof(arr) / sizeof(int);
cout << "Given array is \n";
printArray(arr, arr_size);
mergeSort(arr, 0, arr_size - 1);
cout << "\nSorted array is \n";
printArray(arr, arr_size);
return 0;
}