From 7f4f03aa409f7b688f5494b5a6cfb151c231000c Mon Sep 17 00:00:00 2001 From: Anup Kumar Panwar Date: Sun, 24 Jul 2016 17:17:56 +0530 Subject: [PATCH] Shell Sort --- ShellSort.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ShellSort.cpp diff --git a/ShellSort.cpp b/ShellSort.cpp new file mode 100644 index 000000000..bcda66d4e --- /dev/null +++ b/ShellSort.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; + +int main() +{ + int size=10; + int array[size]; + // Input + cout<<"\nHow many numbers do want to enter in unsorted array : "; + cin>>size; + cout<<"\nEnter the numbers for unsorted array : "; + for (int i = 0; i < size; i++) + { + cin>>array[i]; + } + + // Sorting + for (int i = size/2; i>0 ; i=i/2) + { + for (int j = i; j =0; k=k-i) + { + if (array[k]