// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>


using namespace std;


int main()
{
	int array_size;
	int step = 0;
	cout << "Input array size: \n";
	cin >> array_size;
	cout << "Input array items: \n";
	int *a = new int[array_size];

	for (int i = 0; i<array_size; i++)
	{
		cin >> a[i];
	}


	cout << "\n Our array:\n\n";

	for (int i = 0; i<array_size; i++)
	{
		cout << a[i] << " ";
	}
	cout << "\n\nVisualization\n\n";

	for (int i = 0; i<array_size - 1; i++)
	{
		for (int j = array_size - 1; j>i; j--)
		{
			if (a[j]< a[j - 1])
			{
				swap(a[j], a[j - 1]);
				//visualization
				step++;
				cout << "Step" << step<<" ";

				for (int i = 0; i<array_size; i++)
				{
					cout << a[i] << " ";
				}
				
				cout << "\n\n";
			}
		}
	}

	cout << "\n Our array:\n";

	for (int i = 0; i<array_size; i++)
	{
		cout << a[i] << " ";
	}

	//system("pause");
	return 0;
}