折半查找法
class Program { static void Main(string[] args) { Console.WriteLine("请输入你要查找的信息"); int n =Convert.ToInt32(Console.ReadLine()); int[] a = { 1,3,6,8,10,11 }; int min = 0, max = 11, mid=0; while (min+1!=max) { mid=(min+max)/2; if (n>a[mid]) { min=mid; } else if (n < a[mid]) { max = mid; } else if (n == a[mid]) { Console.WriteLine("输出吧:" + mid); break; } } Console.ReadKey(); } }