#include <stdio.h>

void insertion_sort( int *nArr, int nCount )
{
	int i(0), j(0);
	int key = 0;

	for( i=1 ; i<nCount ; ++i )
	{
		key=nArr[i];
		for( j=i-1 ; j>=0 ; --j )
		{
			if( nArr[j]>key )
			{
				nArr[j+1] = nArr[j];
			}
			else
			{
				break;
			}
		}
		nArr[j+1] = key;
	}
	int a = 9;
}

int main( )
{
	int nArr[] = { 7, 3, 8, 0, 2, 1, 5, 13, 6 };
	int nCount = sizeof(nArr)/sizeof(*nArr);
	
	insertion_sort( nArr, nCount );

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

	return 0;
}


+ Recent posts