From 3e1edca0242d83280bd9088a8ea20839cfa7c8c6 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 30 Jun 2020 22:35:45 +0000 Subject: [PATCH] formatting source-code for efcccd0148923a03eea0fe95c3e27c38e2d9c46d --- sorting/insertion_sort.cpp | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/sorting/insertion_sort.cpp b/sorting/insertion_sort.cpp index 5b20eef47..877e98f27 100644 --- a/sorting/insertion_sort.cpp +++ b/sorting/insertion_sort.cpp @@ -51,9 +51,9 @@ * */ -#include #include #include +#include /** \brief * Insertion Sort Function @@ -76,37 +76,37 @@ void insertionSort(int *arr, int n) { /** Test Cases to test algorithm */ void tests() { - int arr1[10] = { 78, 34, 35, 6, 34, 56, 3, 56, 2, 4}; - insertionSort(arr1, 10); - assert(std::is_sorted(arr1, arr1 + 10)); - std::cout << "Test 1 Passed" << std::endl; + int arr1[10] = {78, 34, 35, 6, 34, 56, 3, 56, 2, 4}; + insertionSort(arr1, 10); + assert(std::is_sorted(arr1, arr1 + 10)); + std::cout << "Test 1 Passed" << std::endl; - int arr2[5] = {5, -3, 7, -2, 1}; - insertionSort(arr2, 5); - assert(std::is_sorted(arr2, arr2 + 5)); - std::cout << "Test 2 Passed" << std::endl; + int arr2[5] = {5, -3, 7, -2, 1}; + insertionSort(arr2, 5); + assert(std::is_sorted(arr2, arr2 + 5)); + std::cout << "Test 2 Passed" << std::endl; } /** Main Function */ int main() { - /// Running predefined tests to test algorithm - tests(); + /// Running predefined tests to test algorithm + tests(); - /// For user insteraction - int n; - std::cout << "Enter the length of your array : "; - std::cin >> n; - int *arr = new int[n]; - std::cout << "Enter any " << n << " Numbers for Unsorted Array : "; + /// For user insteraction + int n; + std::cout << "Enter the length of your array : "; + std::cin >> n; + int *arr = new int[n]; + std::cout << "Enter any " << n << " Numbers for Unsorted Array : "; - for (int i = 0; i < n; i++) std::cin >> arr[i]; + for (int i = 0; i < n; i++) std::cin >> arr[i]; - insertionSort(arr, n); + insertionSort(arr, n); - std::cout << "\nSorted Array : "; - for (int i = 0; i < n; i++) std::cout << arr[i] << " "; + std::cout << "\nSorted Array : "; + for (int i = 0; i < n; i++) std::cout << arr[i] << " "; - std::cout << std::endl; - delete[] arr; - return 0; + std::cout << std::endl; + delete[] arr; + return 0; }