
//*****************************************************************************
////  Course:             COMS 2104 03 Foundations of Computer Programming I
////  Semester:           Spring 2004
////  Assignment Number:  #8                             
////  Author Name:        DarC KonQuesT                        
////  Date Written:       April 15, 2004
////                                                         
////  Description of Program:                              
////  Takes an numeric input and sorts input numbers in ascending numbers    
////  and outputs them in order.                             
////*****************************************************************************
#include <iostream>
using namespace std;


void sort(int& x, int& y, int& z);

int main()
{
	int a,b,c;	
	cout << "Enter three integers: ";
	cin >> a >> b >> c;
	cout << endl;
	cout << "Before sorting:  " << a << " " << b << " " << c << endl;
	sort(a,b,c);
	cout << "After sorting:  " << a << " " << b << " " << c << endl;

return 0;
}


void sort(int& x, int& y, int& z)
{
	int list[3], index, smallest, minIndex, temp;
	list[0] = x;
	list[1] = y;
	list[2] = z;

	for(index = 0; index < 2; index++)
	{
		smallest = index;
		for(minIndex = index + 1; minIndex < 3; minIndex++)
			if(list[minIndex] < list[smallest])
				smallest = minIndex;
		temp = list[smallest];
		list[smallest] = list[index];
		list[index] = temp;
	
	}

x = list[0];
y = list[1];
z = list[2];
}


