#include <iostream>
#include <fstream>
using namespace std;

//Note that since arrays are AUTOMATICALLY passed by reference
//you don't want a & next to v[]
void read (istream & in, int v[], int & n)
{
	int number;
	n=0;
	while (in>>number)
	{
		v[n++]=number;
	}
}

//The following is the familiar bubble sort
void sort (int v[], const int & n)
{
	for (int j=n-1; j>0; j--)
		for (int k=0; k<j; k++)
			if (v[k] > v[k+1])
			{
				int temp=v[k];
				v[k] = v[k+1];
				v[k+1] = temp;
			}
}
		

void write (ostream & out, const int v[], const int & n)
{
	for (int k=0; k<n; k++)
	{
		out << v[k] << endl;
	}
	out << endl;
}

int main()
{
	int	list[100], n;
	
	ifstream fin ("list.txt");
	ofstream fout ("list_out.txt");
	
	read (fin, list, n);
	write (fout, list, n); //Before sorting
	
	sort (list, n);
	
	write (fout, list, n); //After sorting
	
	return 0;
}

