using System;

namespace MyCompiler {
    class Program {
        private static int Bsearch(int[] array, int target) {
            int min = 0;
            int max = array.Length - 1;
            while (max >= min) {
                int mid = (min + max ) / 2;
                if (target == array[mid]) {
                    return mid;
                } else if (target > array[mid]) {
                    min = mid + 1;
                } else {
                    max = mid - 1;
                }
            }
            return -1;
        }
        public static void Main(string[] args) {
            int[] array = {1, 2, 3, 4, 5};
            for (int i = 0; i < array.Length+2; i++) {
                Console.WriteLine(Bsearch(array, i));
            }
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: