zoukankan      html  css  js  c++  java
  • 二分查找

    public bool Search(int[] a,int M)

    {

      return Search(a,0,a.Length-1,M);

    }

    private bool Search(int[] a, int start, int end, int M)

    {

      if(start > end)

      {

        return false;

      }

      if(start == end)

      {

        if(a[start] == M)

        {

          return true;

        }

        else

        {

          return false;

        }

      }

      int mid = (start + end)/2;

      if(a[mid] == M)

      {

        return true;

      }

      else if(a[mid] < M)

      {

        return Search(a,start,mid-1,M);

      }

      else

      {

        return Search(a,mid +1,end,M);

      }

    }

  • 相关阅读:
    python返回函数与匿名函数
    Session&Cookie
    write RE validation
    hello2 source anaylis
    Filter
    Development descriptor
    web.xml配置详解
    Annotation
    injector
    container
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1765658.html
Copyright © 2011-2022 走看看