#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,swap;
	int list[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	
	{	
		srand ((unsigned) time(NULL));

		for (i = 0; i < 10; i++)		
		{	
			list[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 << "] = " << list[i];
		}
		cout << "\n\nthe sorted list \n";
		for (i=0; i<10; i++)
		{
			for (j=i+1; j<10; j++)
			{
					if ( list[i] > list[j])
					{
						swap = list[j];
						list[j] = list[i];
						list[i] = swap;
					}
			}
		}


		for (i=0; i< 10; i++)
		{
			cout << "\nsorted value [" << i+1 << "] = " << list[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";
}
