using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { int ss = 313; int[] str = new int[] { 11, 22, 33, 44, 55, 66, 77, 88, 99 }; int temp = str.Length / 2; while (true) { int flag = str[temp]; if (ss > flag) { temp = temp + (str.Length - temp + 1) / 2; if (temp == str.Length - 1) { if (ss == str[temp]) { Console.WriteLine(temp.ToString()); } break; } } if (ss < flag) { temp = temp / 2; if (temp == 0) { if (ss == str[temp]) { Console.WriteLine(temp.ToString()); } break; } } if (ss == flag) { Console.WriteLine(temp.ToString()); break; } } Console.ReadKey(); } } }