// insertion sort example
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
const int SIZE = 10;
void isort (int Z[], int n) {
int temp;
for (int x = 1; x < n; ++x) {
	temp= Z[x];
	int y = x - 1;
	while ( y >=0 && temp <Z[y]) {
	   Z[y+1] = Z[y];
	   y --;
    }
	Z[y+1] = temp;
	}

}


main () {
   time_t t;
   int z[SIZE];
   int w; 
   srand( (unsigned) time(&t));
   for (w = 0; w < SIZE ; ++w)
        z[w] = rand();
   cout <<"before sorting" << endl;
   for (w=0; w<SIZE; w++)
      cout << z[w] << "  ";
   cout << endl;
   isort(z, SIZE);
   cout << "after sorting" << endl;
   for (w=0; w<SIZE; w++)
      cout << z[w] << "   ";
   cout <<endl;
}
