#include <iostream>
#include <time.h>
using namespace std;

void main (void)
{
	// the next three lines declare the variables that this program	will use
	int i,j, min, pos;
	int value[10], sorted[10]; // value and sorted are array variables which can hold 10 integer values
	char again;

	cout << "This program will sort a list of numbers \n";
	cout << "using an insertion sort \n";
	
	do	
	{	
		min = 1000;
		srand ((unsigned) time(NULL));

		for (i = 0; i < 10; i++)		
		{	
			value[i] = rand()%100;
		}
		
		cout << "\nthe following 10 numbers were generated \n";
		for (i=0; i <10; i++)// this loop displays the numbers generated
		{
			cout << "\nvalue [" << i+1 << "] = " << value[i];
		}
		cout << "\n\nthe sorted list \n";
		for (i=0; i< 10; i++)
		{
			for (j=0; j<10; j++)
			{
				if (min > value[j])
				{
					min = value[j];
					pos = j;
				}
			}
			sorted[i] = min;
			value[pos] = 1000;
			min = 1000;
		}
		for (i=0; i< 10; i++)
		{
			cout << "\nsorted value [" << i+1 << "] = " << sorted[i];
		}
		cout << "\n\nDo you want to generate another list of numbers ? ";
		cin >> again;
	}
	while ((again == 'y') || (again == 'Y'));	// this line checks to see if the user wants another go
	cout << "\n\n	End of program	\n\n";
}
