#include "../CookHeader.h"

Array <Array <int>> ary2 = { {55, 33, 250, 44}, { 88, 1, 67, 23 }, { 199, 222, 38, 47 }, { 155, 145, 20, 99 } };
Array <int> ary1;

Array <int> selctionSort(Array <int> ary) {
	int n = len(ary);
	for (int cycle = 0; cycle < n - 1; cycle++) {
		int minIdx = cycle;
		for (int i = cycle + 1; i < n; i++) {
			if (ary[minIdx] > ary[i])
				minIdx = i;
		}
		int tmp = ary[cycle];
		ary[cycle] = ary[minIdx];
		ary[minIdx] = tmp;
	}
	return ary;
}

int main() {
	for (int i = 0; i < len(ary2); i++)
		for (int k = 0; k < len(ary2[i]); k++)
			ary1.push_back(ary2[i][k]);

	print("1차원 변경 후, 정렬 전 -->");
	printArray(ary1);
	ary1 = selctionSort(ary1);
	print("1차원 변경 후, 정렬 후 -->");
	printArray(ary1);
	print("중앙값 -->");
	println(ary1[ len(ary1) / 2]);
}