rename Sorting -> sorting (#653)

This commit is contained in:
Christian Clauss
2019-11-28 13:32:03 +01:00
committed by GitHub
parent cb1ed9a488
commit f8da1b0685
19 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
//Insertion Sort
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "\nEnter the length of your array : ";
cin >> n;
int Array[n];
cout << "\nEnter any " << n << " 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";
}
return 0;
}