Program 1
// Shall Sort Implementation
#include<iostream>
#define clrscr() system("cls")
using namespace std;
int main()
{
int a[500],n,i,j,gap,temp;
clrscr();
xyz:cout<<"\nEnter the limit of array";
cin>>n;
if(n>500)
{
cout<<"\nInvalid limit enter again";
goto xyz;
}
else
{
cout<<"Enter elements in array";
for(i=0;i<n;i++)
cin>>a[i];
for(gap=n/2;gap>=1;gap=gap/2)
{
for(j=gap;j<n;j++)
{
for(i=j-gap;i>=0;i=i-gap)
{
if(a[i+gap]<a[i])
{
temp=a[i+gap];
a[i+gap]=a[i];
a[i]=temp;
}
else
break;
}
}
}
cout<<"\n Sorted elements: \n";
for(i=0;i<n;i++)
cout<<a[i]<<"\n";
}
return 0;
}