#include <iostream>
using namespace std;

int main() {
	int n = 5;
	int a[n] = {4,3,5,1,2};
	int t,i,j,k;
 
	for (i = 1; i < n; i++) {
		for (k = 0; k < n; k++)
			cout << a[k] << " ";
		cout << endl;
 
		for (j = 0; j < n-i; j++) {
			if (a[j] > a[j+1]) {
				t = a[j];
				a[j] = a[j+1];
				a[j+1] = t;
			}
		}
	}
	cout << "排列好的陣列為" << endl;
	for (i = 0; i < n; i++)
		cout << a[i] << " ";
	// your code goes here
	return 0;
}