#include<iostream>
using namespace std;
int main()
{
int a[8] = {43,18,39,35,17,20,33,34};
int temp,j,high,low,mid;
for(int i=1;i<=7;i++)
{
temp = a[i];
low = 0;
high = i-1;
while(low<= high)
{
mid = (low+high)/2;
if(a[mid]>temp)
high = mid-1;
else
low = mid+1;
}
for(int j=i-1;j>high;j--)
a[j+1] = a[j];
a[high+1] = temp;
}
for(int i = 0;i < 8; i++)
{
cout<<a[i]<<endl;
}
system("pause");
return 0;
}
using namespace std;
int main()
{
int a[8] = {43,18,39,35,17,20,33,34};
int temp,j,high,low,mid;
for(int i=1;i<=7;i++)
{
temp = a[i];
low = 0;
high = i-1;
while(low<= high)
{
mid = (low+high)/2;
if(a[mid]>temp)
high = mid-1;
else
low = mid+1;
}
for(int j=i-1;j>high;j--)
a[j+1] = a[j];
a[high+1] = temp;
}
for(int i = 0;i < 8; i++)
{
cout<<a[i]<<endl;
}
system("pause");
return 0;
}