/* 
 * 		Kennsluáætlun í T-111-PROG, Forritun, 2009-3
 * 
 * 						~Dæmi 2~
 * 
 * 		Dæmi 6 úr kafla 7 í kennslubók á bls. 466.
 * 
 * 		Nemandi: Baldur Blöndal
 * 		Kennari: Hallgrímur Arnalds
 * 
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

# include <iostream>
using namespace std;

void sort( int fylki[], const int LENGD)
{
	int store = 0;
	int newfylki[LENGD];
	
	for (int n = 0; n < LENGD; n++)
	    newfylki[n] = fylki[n];
	
	for (int i = 1; i < LENGD; i++)
	{
		for (int j = 0; j < i; j++)
		{
			if (newfylki[i] < newfylki[j]) // i=1 j=0
			{
				store = newfylki[j];
				newfylki[j] = newfylki[i];
				newfylki[i] = store;
			}
		}
	}
	cout << "{";
	for (int k = 0; k < LENGD; k++)
	{
		cout << newfylki[k];
		if (k < (LENGD - 1))
		{
			cout << ", ";
		}
	}
	cout << "}"  << endl;
}

int main ()
{
	//int a[10] = {6,8,10,2,16,4,18,14,10,12};
	int a[5] = {6,2,199,4,-2};
	
	sort(a, 5);
	
	return 0;
}
