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

