From 71f5641eb4fb63dd3544393965011b896b96e431 Mon Sep 17 00:00:00 2001 From: beqakd <39763019+beqakd@users.noreply.github.com> Date: Mon, 8 Jun 2020 10:16:29 +0400 Subject: [PATCH] Delete GnomeSort.cpp --- sorting/GnomeSort.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 sorting/GnomeSort.cpp diff --git a/sorting/GnomeSort.cpp b/sorting/GnomeSort.cpp deleted file mode 100644 index c225c6277..000000000 --- a/sorting/GnomeSort.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -using namespace std; - -void GnomeSort(int arr[], int size) { - // few easy cases - if (size <= 1) return; - - int index = 0; // initialize some variables. - while (index < size) { - // check for swap - if ((index == 0) || (arr[index] >= arr[index - 1])) { - index++; - } else { - swap(arr[index], arr[index - 1]); // swap - index--; - } - } -} -// Our main function -int main() { - int arr[] = {-2, -10, 100, 35, 34, 99}; - int size = sizeof(arr) / sizeof(arr[0]); - - GnomeSort(arr, size); - - for (int i = 0; i < size; i++) printf("%d ", arr[i]); - - return 0; -}