// InsertSort.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int * InsertSort(int Arry[],int n)
{
	int pos2Insert;
	int tmpKard;

	for(int i=1;i<n;i++)
	{
		tmpKard=Arry[i];
		pos2Insert=i;
		for(int j=i-1;j>=0;j--)
		{
			if (tmpKard<Arry[j])
			{
				Arry[j+1]=Arry[j];
				pos2Insert=j;
			}
		}
		Arry[pos2Insert]=tmpKard;
	}
	return Arry;
}

void printArry(int Arry[],int n)
{
	for(int i=0;i<n;i++)
		printf("%d ",Arry[i]);
	printf("\n");
}

int main(int argc, char* argv[])
{
	int a[]={1,7,5,3,4,6,8};

	printArry(InsertSort(a,sizeof(a)/sizeof(int)),sizeof(a)/sizeof(int));
	printf("Hello World!\n");
	return 0;
}

/*
1 3 4 5 6 7 8
Hello World!
Press any key to continue
*/