1. #include <stdio.h>
    2. void InsertionSort( int A[], int N );
    3. int main(void)
    4. {
    5. int A[6] = { 8, 34, 64, 51, 32, 21 };
    6. InsertionSort( A, 6 );
    7. for( int i = 0; i < 6; i++ )
    8. printf( "%d ", A[i]);
    9. return 0;
    10. }
    11. void InsertionSort( int A[], int N )
    12. {
    13. int j, P;
    14. int Tmp;
    15. for( P = 1; P < N; P++ )
    16. {
    17. Tmp = A[ P ];
    18. for( j = P; j > 0 && A[ j - 1] > Tmp; j-- )
    19. A[ j ] = A[ j - 1];
    20. A[ j ] = Tmp;
    21. }
    22. }