// 100_42.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int find(int * arr, int left, int right)
{
if(left==right-1)
return arr[right];
int mid = (left+right)/2;
if(arr[mid] > arr[left])
{
return find(arr,mid,right);
}
else
{
return find(arr,left,mid);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int arr[] = {3,4,1};
printf("%d\n",find(arr,0,2));
return 0;
}
浙公网安备 33010602011771号