#include <cstdio>
#include <iostream>

template<typename T, bool low_to_high>
void bubblesort(T* x, unsigned size)
{
	for (unsigned i = 0;  i < size - 1;  ++i)
    {
        for (unsigned j = 0;  j < size - i - 1;  ++j)
        {
            if (low_to_high ? x[j] > x[j + 1] : x[j] < x[j + 1])
            {
            	T temp = x[j];
                x[j] = x[j + 1];
                x[j + 1] = temp;
            }
        }
    }
}

void print(int* a, unsigned size)
{
	for (unsigned i = 0; i < size - 1; ++i)
	{
		std::cout<<a[i]<<" ";
	}
	
	std::cout<<a[size - 1]<<"\n\n";
}

int main()
{
	int a[12] = {0};
	unsigned len = sizeof(a)/sizeof(a[0]);
	
	std::cout<<"Enter "<<len<<" numbers: ";
	for (unsigned i = 0; i < len; ++i)
	{
		std::cin>>a[i];
		std::cin.ignore();
	}

	std::cout<<"\n\n";
	
	bubblesort<int, true>(a, len);
	print(a, len);
	
	bubblesort<int, false>(a, len);
	print(a, len);
}