#include "..\CookHeader.h"

Array <int> dataAry = { 50, 60, 105, 120, 150, 160, 162, 168, 177, 188 };

int binSearch(Array <int> ary, int fData) {
	int pos = -1;
	int start = 0;
	int end = len(ary) - 1;

	while (start <= end) {
		int mid = (start + end) / 2;
		if (fData == ary[mid])
			return mid;
		else if (fData > ary[mid])
			start = mid + 1;
		else
			end = mid - 1;
	}
	return pos;
}

int main() {
	int findData = 162;

	print("배열-->");
	printArray(dataAry);
	int position = binSearch(dataAry, findData);
	if (position == -1) {
		println(to_string(findData) + "이(가) 없네요.");
	}
	else {
		println(to_string(findData) + "은(는) " + to_string(position) + " 위치에 있음");
	}
}