#include <iostream>
#include<time.h>
using namespace std;

void main (void)
{
	int i, j, list[10], sorted[10];
	int highest = 0;
	int lowest = 5000;
	int minLoc=0, maxLoc = 0;;
	//int sum = 0;
	//float avg;
	srand ((unsigned) time(NULL));

	for (i=0; i<10; i++)
	{
		list[i] = rand()%20 + 1;
	}
	for (i=0; i<10; i++)
	{
		cout << list[i] << endl;
	}
	cout << "In descending order : "<< endl;
	for (j=0; j<10; j++)
	{
		int highest = 0;
		int lowest = 5000;
		for (i=0; i<10; i++)
		{
			if (list[i] > highest)
			{
				highest = list[i];
				maxLoc = i;
			}
			if (list[i] < lowest)
			{
				lowest = list[i];
				minLoc = i;
			}
		}
		//cout << "The highest number is : " << highest << endl;
		//cout << "The lowest number is : " << lowest << "at location " << minLoc << endl;
		sorted[j] = list[maxLoc];
		list[maxLoc] =0;
	}

	for (i=0; i<10; i++)
	{
		cout << sorted[i] << endl;
	}
	//cout << "The lowest number has been written to the sorted array : " << sorted[0] << endl;
	/*for (i=0; i<10; i++)
	{
		sum = sum + list[i];
	}
	cout << "The sum of the numbers is : " << sum  << endl;
	avg = (float)sum/10;
	cout << "The average of the numbers is : " << avg  << endl;*/

}