This commit is contained in:
AnupKumarPanwar
2017-02-20 09:08:44 +05:30
parent d26234f860
commit 1c1746bc64
9 changed files with 14 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
//Insertion Sort
#include<iostream>
using namespace std;
int main()
{
int n;
int Array[n];
cout<<"\nEnter any 6 Numbers for Unsorted Array : ";
//Input
for(int i=0; i<n; i++)
{
cin>>Array[i];
}
//Sorting
for(int i=1; i<n; i++)
{
int temp=Array[i];
int j=i-1;
while(j>=0 && temp<Array[j])
{
Array[j+1]=Array[j];
j--;
}
Array[j+1]=temp;
}
//Output
cout<<"\nSorted Array : ";
for(int i=0; i<n; i++)
{
cout<<Array[i]<<"\t";
}
}