From 42ae48592ac54a6571f6c3c0292d66d77206bc87 Mon Sep 17 00:00:00 2001 From: Anup Kumar Panwar Date: Tue, 19 Jul 2016 12:32:14 +0530 Subject: [PATCH] insertion sort --- InsertionSort.cpp | 37 +++++++++++++++++++++++++++++++++++++ searching.cpp | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 InsertionSort.cpp diff --git a/InsertionSort.cpp b/InsertionSort.cpp new file mode 100644 index 000000000..1123543d5 --- /dev/null +++ b/InsertionSort.cpp @@ -0,0 +1,37 @@ +//Bubble Sort + +#include +using namespace std; + +int main() +{ + int Array[6]; + cout<<"\nEnter any 6 Numbers for Unsorted Array : "; + + //Input + for(int i=0; i<6; i++) + { + cin>>Array[i]; + } + + //Sorting + for(int i=1; i<6; i++) + { + int temp=Array[i]; + int j=i-1; + while(j>=0 && temp