public class BinarneHladanie
public static int Binsearch(int[] pole, int hladanyPrvok)
int pravy = pole.Length - 1;
int stred = (lavy + pravy) / 2;
if (hladanyPrvok == pole[stred])
else if (hladanyPrvok > pole[stred])
public static void Main(string[] args)
int[] pole = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 };
int vysledok = Binsearch(pole, hladanyPrvok);
Console.WriteLine("Prvok " + hladanyPrvok + " je na indexe " + vysledok + ".");
Console.WriteLine("Prvok " + hladanyPrvok + " nie je v poli.");