旋转数组的最小数字

#include 
#include 

using namespace std;
int inorder(int a[],int index1, int index2)
{
    int mini=index1;
    for(int i = index1 + 1;i <= index2; i++)
        if(a[mini]>a[i])
            a[mini]=a[i];
    return a[mini];
}
int Min(int a[],int len)
{
    int index1 = 0;
    int index2 = len-1;
    int mid = index1;
    while(a[index1] >= a[index2])
    {
        if(index2 - index1 ==1)
            return a[index2];
        mid = (index1 + index2)/2;

        if( a[mid] == a[index1] && a[index1] == a[index2])
            return inorder(a,index1,index2);

        if(a[mid] > a[index1])
            index1 = mid;
        else
            if(a[mid]

转载于:https://www.cnblogs.com/xiaofeiwang/p/3825007.html

你可能感兴趣的:(旋转数组的最小数字)